Getting current row number in which row is inserting in SQL table
In this tutorial you will learn about that how you can retrieve the current row number of the inserting row in the SQL table.
$db = new mysqli('localhost','root','','shop');//code from database.php file
$insert_into_product = "INSERT INTO product(product_name,product_description,brand,product_quantity,product_price) VALUES('$product_name','$product_description','$brand','$product_quantity','$product_prices')";
$response_insert = $db->query($insert_into_product);
if($response_insert){
$current_id = $db->insert_id;
}
echo $current_id;
Explanation -
In line 9 we are insert_id method from the $db ($db variable is define in another page which is database.php for setting up connection with database) it will give the current row number in which row is inserting in table.
0 Comments
Please do not enter any spam link in comment box.