I have a website, you can upload pictures via php/mysgl into a database, and the homepage randomly shows the pictures when you click on them.
When someone uploads a photo I want to be able to redirect to the homepage and spit out a value in the database, instead of showing a random photo, I want to show the photo they uploaded.
So I have something like this…
Database
table name – posts
primary key – ID
var – name
var – location
var – caption
var – imageURL
I understand If/else
I don’t understand…
How do I write
mysql_select_db(‘posts’)
find LAST row ID
find the var name in that row/ID
echo out the value inside the row ‘name’
Do this:
$result = mysql_query("select id, name, location, caption, imageUrl from your_tablename order by id desc limit 1"); while ($row = mysql_fetch_assoc($result)) { echo $row['id']; echo $row['name']; echo $row['caption']; echo $row['imageUrl']; }Hope it helps