如何将ID从一个页面传递到另一个页面在PHP中? [英] how to pass id from one page to another page in php?

查看:415
本文介绍了如何将ID从一个页面传递到另一个页面在PHP中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

产品详细信息有两个表格,产品图片的第二个表格

第一页是产品详细信息产品详细信息页面插入产品详细信息。因此,如何获取最近插入的产品的id,并将该id重定向到另一个页面以插入该产品图像。



我想从一个页面传递产品ID到另一个页面插入该产品图像

id可以通过url传递,但我不知道如何传递。



这两张表对于产品细节和产品图片都是不同的。



plz为其提供代码...



在此页面中,产品详细信息插入了此新近插入的产品的ID,并且我想在另一个页面中传递该消息





我想要产品ID在这里:

p>

解决方产品详情.php


$ b $ 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

 <?php 

if(isset($ _ GET ['id'])){
$ lastId = $ _GET ['ID'];
//用最后插入的产品id做



?>

或尝试会话:

product-details.php

 <?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

 <?php 
session_start();
if(isset($ _ SESSION ['last_id'])){

$ lastId = $ _SESSION ['last_id'];
//用最后插入的产品id做



?>


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

<?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

<?php

if(isset($_GET['id'])){
     $lastId = $_GET['id'];
     // do stuff with this last inserted product id
}


?>

or try sessions:

product-details.php

<?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

<?php
session_start();
if(isset($_SESSION['last_id'])){

     $lastId = $_SESSION['last_id'];
     // do stuff with this last inserted product id
}


?>

这篇关于如何将ID从一个页面传递到另一个页面在PHP中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆