65 id productdet.php,如何将ID从一个页面传递到另一个页面在PHP中?

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

3d18b91beb9c8a63c9ac409d1e5637ce.png

i want product id here:

c4e5b479a3d4cc735d37e06d4c05db43.png

解决方案

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

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值