PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
i made a small script for highscore table, but it aint working as it should be. Any1 can tell me for show me mistakes? or give me advice how should do it?
Whats the problem is, i wanted to make it so, that $row[online] would change to image what will come from echos.
Anyways here is the current code:
<?PHP
<!---------------------- Code A Starts -------------------->
<!-- Made the code more simple -->
if($row[Online]=='JAH')
echo ('image-online');
if($row[Online]=='Ei')
echo ('image-offline');
<!---------------------- Code A Ends -------------------->
<!-- Echos pops up here -->
<!-- Code B Starts -->
$result = mysql_query("SELECT * FROM kasutajad ORDER BY Raha DESC LIMIT 100");
$i = 1;
while($row = mysql_fetch_array( $result ) )
{
echo(
"<tr>
<td>$i</td>
<td>");?> <a href="kasutaja.php?id=<?php echo ("$row[kasutaja]"); ?>"><?php echo ("$row[kasutaja]"); ?><?php echo ("</a><td>$online</td></td>
<td>$row[Online]</td> <!-- that row still wount take the echos above, what makes me worry. Echos pops up from top of table, but i actualy wants it to pop up, if the Online row is used in table (here) -->
</tr>"
);
$i++;
}
?>
<?PHP
<!---------------------- Code A Starts -------------------->
<!-- Made the code more simple -->
if($row[Online]=='JAH')
echo ('image-online');
if($row[Online]=='Ei')
echo ('image-offline');
<!---------------------- Code A Ends -------------------->
$row hasn't been defined at this point in the code, so both conditions fail. Even if they didn't, your echo statements would output the words 'image-online' (or -offline) rather than an image, which I think you're expecting.
I've noticed you're also echoing $online farther down the code, but $online has also not been defined.