Get last inserted record ID PHP-MySQL

This function gets last inserted records ID

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;
}

Blinklist Blogmarks del.icio.us Digg Ma.gnolia My Web 2.0 Newsvine Reddit Segnalo Simpy Spurl Wists Technorati



Recommended

Link Partners

Web Design Forum