Let’s say I have a database(PHOTOALBUM) and a table (ALBUMS) with three columns:
ID, Name, Date
I want a script where it shows me ONLY the highest ID. Let’s say I have 10 names. I want the variable $id to have number 10 inside. Here’s what I have but doesn’t work as I want it to.
I want the last ID so I can have ID + 1 and insert a new ID number.
$sql = “SELECT * FROM albums”;
if (!$sql)
{
echo(“Could not select data from table”);
exit();
}
$result = mysql_db_query(‘photoAlbum’, $sql);
if (!$result)
{
echo(“Database query not successful”);
exit();
}
$row = mysql_fetch_array($result);
if (!$sql)
{
echo(“Could not retrieve array”);
exit();
}
$id = $row[“description”];
if (!$sql)
{
echo(“Could not retrieve row”);
exit();
}
echo (’<p>’ . $id . ‘</p>’);
Any suggestions?
Thanks!