Jump to content

Problem with listing images from database [RESOLVED]


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]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.