$query=mysql_query("SELECT MAX(id) AS max FROM table_name"); $max_line=mysql_Fetch_Array($query);echo $max_line['max'];