Introductions are in order… I’m a total newbie to PHP. I haven’t read many tutorials – mostly because they were all too technical for me, and I only really wanted a list of the various commands I could use. Most if not all I’ve learned of PHP I’ve gotten from reading code and fiddling about with it untill it works. But this latest idea of mine has me stumped. I just can’t get my head around it. Each time I do something I think should work, it goes wonky. So now I’m giving it to you… if someone could just point out what I’m doing wrong, I’d be very greatfull.
If someone could give me the url of a guide like I described, I’d also be greatfull.
Thanks!
Emanuel
<?php
if ($characters[$i]['character_player']) // Character has a player.
{
$playercount = 0;
for ($p = 0; $p < count($players); $p++) // Begining of player loop.
{
if ($players[$p]['username'] == $characters[$i]['character_player']) // The players username matches the character's player.
{
$playercount = 1;
if ($players[$p]['user_realname']) // The player has a real name.
{
?>
<B> Player: </B> <A HREF="players.php#<?php echo $players[$p]['username']; ?>"> <?php echo $players[$p]['user_realname']; ?> </A> <BR>
<?php
}
else // Player has no real name.
{
?>
<B> Player: </B> <A HREF="players.php#<?php echo $players[$p]['username']; ?>"> <?php echo $players[$p]['username']; ?> </A> <BR>
<?php
}
}
else // The players username does not equal that of the character's player.
{
?>
<?php
}
if ($p = count($players)) // If the script has gone through all the players.
{
if ($playercount < 1) // And has yet to find a match.
{
?>
<B> Player: </B> <?php echo $characters[$i]['character_player']; ?> </A> <BR>
<?php
}
else // And has found a match
{
?>
<?php
}
}
else // If the script hasn't gone through all the players... don't do anything.
{
?>
<?php
}
} // End of player loop.
}
else // Character has no player.
{
?>
<B> Player: </B> Unknown <BR>
<?php
}
?>