Upload an image and assigning it a new id

I’m still a bit new to php, so bear with me. I’m trying to create a site where a visitor can upload an image, and that image is then set as the first position (it’s a 100-latest-submissions site) and whatever image was at position 1 is now automatically at position 2, and this trend continues up until the 100th position, or slot.

My main question is: How or what do I need to do to set it up so the latest uploaded image is assigned the id=1, and the second latest image that was uploaded to the database that had id=1 is now id=2, and so on (up until 100).

I’m also creating 100 individual pages that displays the image:

for page 1 (same format applies to all 100 pages).

If you had a database with the images in, you could run a query that would get the most recent items. Assuming, you had an image_path and id field (ID being a primary key and auto incrementing):

[php]$query = mysql_query(‘SELECT * FROM your_table_name ORDER BY id DESC LIMIT 0,100’);

// Then:

foreach($query as $photo) {
echo ‘’;
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service