$q = "select MAX(id) from table1"; $result = mysql_query($q); $data = mysql_fetch_array($result);
echo $data[0];