mostwanted Posted June 7, 2008 Share Posted June 7, 2008 Below is my code I have set to display my images from my database, which works fine.. But I need help.. I need to display the images in a set number of columns... Could someone please help me on this or lead me in the right direction? Thank you in advance! <? include "_dbconnect.php"; $imagesql = mysql_query("SELECT * FROM images ORDER BY id DESC LIMIT 10"); $theid=$imagesql->id; while($image=mysql_fetch_object($imagesql)){ ?> <td><a href="imagecode.php?id=<?=$image->id?>"><img src="<?=$image->url?>" border="0" width="150"></td> <? } mysql_close($db); ?> Link to comment https://forums.phpfreaks.com/topic/109094-display-images-from-database-in-columns/ Share on other sites More sharing options...
blueman378 Posted June 9, 2008 Share Posted June 9, 2008 <? include "_dbconnect.php"; $imagesql = mysql_query("SELECT * FROM images ORDER BY id DESC LIMIT 10"); $theid=$imagesql->id; $columns = 10; // the amount of columns you want while($image=mysql_fetch_object($imagesql)){ ?> <td><a href="imagecode.php?id=<?=$image->id?>"><img src="<?=$image->url?>" border="0" width="150"></td> <? $count++; if($count == $columns) { echo "</tr><tr>"; $count = 0; } } mysql_close($db); ?> Link to comment https://forums.phpfreaks.com/topic/109094-display-images-from-database-in-columns/#findComment-560812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.