Forum Moderators: coopster

Message Too Old, No Replies

Displaying the last 8 added images.

in a table 2 rows by 4 columns using MySQL query.

         

ShoT

1:39 am on Mar 13, 2006 (gmt 0)

10+ Year Member



Hey guys,
I have written an upload script that automatically saves the image name to a MySQL DB and has an Auto Incremented id.

Now, to display the last 8 images added I would use:


$result = mysql_query("SELECT * FROM recentimages ORDER BY id DESC LIMIT 8",$connect);

However, if I start the loop with an image whose src is the result of the query in a table it's going to repeat the table each time with a different image.

I have no clue how to get it into a table thats 4 columns by 2 rows displaying 1 of the 8 images in each cell, please help if you can. Thanks in advance.

omoutop

8:34 am on Mar 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



run your loop , but instead of showing the images, add them in an array (the end result would be an array with the correct order of images you wanna show).

After you hace constructed your array, just echo the variuous elements, so for example, at first cell you will show array element 0, at next cell, array element 1 and so forth

coopster

2:36 pm on Mar 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Hi ShoT, and welcome to WebmasterWorld.

There are quite a few examples on the forum that describe how to loop and display images using MySQL and PHP. A quick search turned up this example that may help ...

[webmasterworld.com...]