AdRock Posted December 6, 2006 Share Posted December 6, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/29732-problem-with-listing-images-from-database-resolved/ Share on other sites More sharing options...
kenrbnsn Posted December 6, 2006 Share Posted December 6, 2006 Please post your code.Ken Quote Link to comment https://forums.phpfreaks.com/topic/29732-problem-with-listing-images-from-database-resolved/#findComment-136496 Share on other sites More sharing options...
AdRock Posted December 6, 2006 Author Share Posted December 6, 2006 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 endedif ($count % NUMCOLS != 0) { while ($count++ % NUMCOLS) echo "<td> </td>"; echo "</TR>\n";}echo "</TABLE>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/29732-problem-with-listing-images-from-database-resolved/#findComment-136500 Share on other sites More sharing options...
the_oliver Posted December 6, 2006 Share Posted December 6, 2006 not sure if there a simpler way, but you could create a nother columb in your db table, put a 1 it for all files you want, and refine your serch to only include results where there is a 1 in this field. Quote Link to comment https://forums.phpfreaks.com/topic/29732-problem-with-listing-images-from-database-resolved/#findComment-136524 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.