如何获得下一个用户ID?

I am trying print two rows, this is code for the first next user, first with next five users and second with next 25 users after 5, I am getting an error while getting next id

 $query = mysql_query("SELECT * FROM user ORDER BY  id  ASC ");

 while($auto_inc_result = mysql_fetch_array($query))
 {
     $last_id = $auto_inc_result['id'];
 }

 $next_id = ($last_id+1);

 echo $next_id;

I tried this also but it didn't work also

SELECT * 
FROM User 
WHERE id>$_SESSION['id'] 
ORDER BY id ASC
LIMIT 25

Dont calculate you next value in PHP, because your value is calculated in database side.

Use this query:

SELECT AUTO_INCREMENT
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = "yourDatabaseName"
AND TABLE_NAME = "yourTableName"