loop won't display all images
Posted: Wed Dec 31, 2003 9:47 am
The following code displays a table of images, but for some reason will not display every image. Also, it prints one empty cell at the end.
Can anyone tell me why?
[Edit: Added php tags for eyecandy --JAM]
Can anyone tell me why?
Code: Select all
<?php
$result = mysql_query( "SELECT * FROM images" );
$num_rows = mysql_num_rows($result);
print $num_rows;
?>
<table border=1 width=100% height=100%>
<tr>
<?php
for ($count=0; $count <= $num_rows; $count++) {
$a_row = mysql_fetch_array($result);
if (($count % 4) == 0 ) {
print "</tr><tr>\n";
}else{
print "\t<td><img src = "/images/thumbnails/$a_row[imagename]"></td>\n";
}
}
?>
</table>
<?php mysql_close( $link ); ?>