PHP Noob here - trouble displaying last value in an array
Posted: Mon Sep 27, 2010 2:16 pm
Hey, as I said, I am working on my very first project in php. So far so good! However, there is something I can't get past. I am sure it's simple, I am just missing it.
The problem is that, while my data fills out the table very nicely, it does not include the last row. If there are 3 entries, it will only show 4, etc.
Here's my code:
I'm a little, tiny baby.
The problem is that, while my data fills out the table very nicely, it does not include the last row. If there are 3 entries, it will only show 4, etc.
Here's my code:
Code: Select all
$row = mysql_fetch_array($result);
$rowcolor = 1;
while($row = mysql_fetch_array($result))
{
if ( $rowcolor==2 ) { echo "<tr class='rowColorDark'><td>"; $rowcolor = 0; } else { echo "<tr class='rowColorLight'><td>"; }
echo $row['distroname'] . "</td><td>" . $row['logins'] . "</td><td>" . $row['lastlogin'] . "</td><td>" . $row['username'] . "</td><td>" . $row['password'] . "</td></tr>";
$rowcolor++;
}