I need to display the next id from a table but if there isn't a next id, I'll display the first id of the table.
Despite a lot of tries, I was just able to display next id if next id follow +1 like my sample Can you help me to custom my script ? Thank you very much for helping
<?php // verify that id+1 exist
$verif_page_next = $planning_id +1;
$req = mysql_query("SELECT id FROM planning WHERE id = '" . $verif_page_next . "'")
or exit(mysql_error());
if (mysql_num_rows($req) == 1) {
$next_page = $verif_page_next ;
}
// we start the first id
else {
$next_page = 1 ;
}
?>
So, if I delete an ID (e.g the ID 3), it restart to the first ID, and I wish to jump to the ID n° 4