There is two table one for product details and second for product images..
first page is product detail and product details page insert the product details. So how to fetch the id of that recent inserted product and that id redirect to another page for insertion of that product image..
i want to pass product id from one page to another page for insertion of that product image
id can pass through url but i don't know how to pass..
Both table are different for product detail and product image
plz provide code for it...
In this page product detail inserted and id of this recent inserted product i want to pass in another page
i want product id here:
解决方案
product-details.php
$result = mysqli_query($connection, $some_insert_query_here);
if($result){
$lastId = mysqli_insert_id($connection);
header("Location: product-image.php?id=".$lastId);
}
?>
product-image.php
if(isset($_GET['id'])){
$lastId = $_GET['id'];
// do stuff with this last inserted product id
}
?>
or try sessions:
product-details.php
$result = mysqli_query($connection, $some_insert_query_here);
if($result){
$lastId = mysqli_insert_id($connection);
session_start();
$_SESSION['last_id'] = $lastId;
header("Location: product-image.php");
}
?>
product-image.php
session_start();
if(isset($_SESSION['last_id'])){
$lastId = $_SESSION['last_id'];
// do stuff with this last inserted product id
}
?>