Jump to content

Display images from database in columns...


mostwanted

Recommended Posts

 

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

<?
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);
?>

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.