$query = mysql_query("SELECT MAX(id) FROM lentele"); while($row = mysql_fetch_array($query)) { echo $row['id']; }