如何将ID从一个页面传递到另一个页面在PHP中?

编程入门 行业动态 更新时间:2024-10-25 15:19:59
本文介绍了如何将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中?

本文发布于:2023-05-25 10:57:10,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file &#039;D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!