I want to get the id of the most recently added item to my database and have the following statement
SELECT id FROM talks ORDER BY date_added DESC LIMIT 1;
The works using Firefox’s SQLite manager but I cannot work out the PHP I need to get the result. Can anyone help please?
EDIT
I have found that the following will do the job. However, is there an alternative to the foreach loop? Given there is only one result it seems rather daft!
$query = 'SELECT id FROM talks ORDER BY date_added DESC LIMIT 1;';
$result = $db->query($query);
foreach ( $result as $row )
$id = $row['id'];