Answer the question
In order to leave comments, you need to log in
How to fix glitches with SELECT MAX(`id`)?
There is a code
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT MAX(`id`) FROM `ia`";
$result = $conn->query($sql);
$row = $result->fetch_row();
$firstField = $row[0];
$nextID = $firstField +1 ;
Answer the question
In order to leave comments, you need to log in
I'm not sure if this will help 100%, I haven't tested the logic of this function, but it's worth a try:
In other words:
*I didn't notice right away... But after that with autoincrement it won't be superfluous.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question