Home » Php » How to get Last Inserted Id From Database Php Mysqli

How to get Last Inserted Id From Database Php Mysqli

Posted by: admin February 25, 2020 Leave a comment

Questions:

I want to know how can i get last inserted id from database table in php mysqli

i have tried this code which is in php mysql….

<?php

include('config.php');

$query1 = "SELECT id FROM tablename ORDER BY id DESC
LIMIT 1;";
$result = mysql_query($query1);
$data = mysql_fetch_array($result);

echo "<a href='example.com/edit.php?id={$data[0]}'>Click Here !!</a>";

?>

But i want to update same code for php mysqli also….

can anyone help me….

How to&Answers: