Afdrukken
Categorie: PHP
Hits: 2577

Get last inserted record from your mysql database

 

This function gets last inserted record (ID) from your MySQL database.

function select_max_id($id="id",$my_table="cms_pages")
{
$db = new clsDBcms();//You may have different connection class

$SQL = "SELECT MAX($id) FROM ".$my_table;
$db->query($SQL);
if ($db->next_record())
{
$max_id = $db->f(0);
}
$db->close();
return $max_id;
}

 

http://www.vision.to/get-last-inserted-record-id-phpmysql.php