Jump to content

Problem with listing images from database [RESOLVED]


AdRock

Recommended Posts

I have a small image gallery and I am having problems listing the images from the database.

I can see all the thumbnails is my database but there is always an extra image that doesn't exist shown on the page and I don't know why it's there as I have 35 images stored in the database and the page is showing 36 (36 being an image that doesn't exist).

Is there a way of removing the non-existent image.  I think it's something to do with $count or $counter
Sorry....forgot  ;D

[code]<h2>Image Gallery - Jack</h2>
<?php
$cat = $_GET['cat'];

define ("NUMCOLS",4);

include_once("includes/connection.php");

$res = mysql_query("SELECT id,thumb,cat FROM images WHERE cat='jack'");

$count = 0;
$counter= 1;
echo "<TABLE border=0 id='gallery'>";
while (list($id,$thumb,$cat) = mysql_fetch_row($res)) {

    if ($count % NUMCOLS == 0) echo "<TR>\n";  # new row
    echo "<TD><div class='img-shadow'><a href='/gallery/$cat/image/$counter'><img src='/images/gallery/thumbs/$thumb' style='border:none'></a></div></TD>\n";
    $count++;
    $counter++;

    if ($count % NUMCOLS == 0) echo "</TR>\n";  # end row
}

# end row if not already ended

if ($count % NUMCOLS != 0) {
  while ($count++ % NUMCOLS) echo "<td>&nbsp;</td>";
  echo "</TR>\n";
}
echo "</TABLE>";
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.