Reputation: 299
I want to get the maximum id from a table.
If I use mysqli_insert_id
, then it gives 0 value.Plz help or suggest any other approach to get last/max id from table
$pre_id = $_POST['last_id'];
$sql = mysqli_query($db3->connection, "SELECT * FROM chat where id=>_pre_id");
$id = mysqli_insert_id($db3->connection);
echo $id;
Upvotes: 0
Views: 53
Reputation: 133
Is that you want ?
SELECT * FROM chat ORDER BY id DESC LIMIT 0,1
Upvotes: 2