okay, since you didn't see my post above
<?php
//connection string omitted
$query = "SELECT id FROM celebs ORDER BY id DESC";
$results = mysql_query($sql);
if(mysql_num_rows($results) > 0) {
echo "Max id: " . mysql_result($result,0,0);
} else {
echo "No data in celebs table";
}
?>
you can make this into a function like this
<?php
function get max_id($server = 'localhost',$dbname,$username,$password,$id_field,$table) {
$db_conn = mysql_connect($server,$username,$password);
mysql_select_db($dbname);
$sql = "SELECT " . $id_field . " FROM " . $table . " ORDER BY " . $id_field . " DESC";
$query = mysql_query($sql);
if(mysql_num_rows($query) > 0) {return mysql_result($query,0,0);}
else {return 0;}
} //end get max
?>