[英]i have a problem with storing data into database, anyone can help me?
[英]Can anyone help me to pass data fetched from mysql database in a table to another page on submit?
我正在开发一个用于书籍的电子商务站点。当用户搜索特定的书籍类别时,则使用php和mysql从数据库中获取与该类别相关的书籍,并在带有立即购买按钮的表中显示。当用户单击特定ISBN号的购买按钮时然后将其重定向到购买页面,用户必须提供所选ISBN编号的帐单信息。但是问题是,在单击“立即购买”按钮时,特定ISBN不会传递到购买页面中。 这是我的searchresult.php代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<table class="table table-condensed" style="margin-bottom:0px">
<thead>
<tr class="cart_menu">
<td class="image"></td>
<td class="description">Book Name</td>
<td class="description">ISBN Number</td>
<td class="description">Price</td>
<td></td>
</tr>
</thead>
<tbody>
<?php
@$query=("SELECT * from book where category='computer science'");
@$res=mysql_query($query);
while(@$row=mysql_fetch_assoc($res)) { ?>
<tr>
<td class="cart_description">
<h5><?php echo $row['name'] ?></h5>
</td>
<td class="cart_description">
<h5><?php echo $row['ISBN'] ?></h5>
</td>
<td class="cart_description">
<h5>$<?php echo $row['price'] ?></h5>
</td>
<td>
<?php echo'<a class="btn btn-primary" name="ISBN" style="margin-top:0px;" href="cart.php?ISBN=' . $row['ISBN'] . '">Buy Now</a>';?>
</td>
</tr>
<?php } ?>
</tbody></table>
</body>
</html>
当用户单击“立即购买”按钮时,它将重定向到cart.php
我在哪里从searchresult.php提取操作数据,即ISBN号为:
<?php echo $_GET['ISBN']; ?>
但是在重新加载页面后,ISBN号消失了。
请帮助我传递ISBN号并存储在那里,直到完成书的购买为止。
当人们评论时,我认为您使用的单词refresh错误。 如果要将购物车中的物品保留在您选择的GET或POST变量中。 我个人认为这很疯狂,您应该将它们放在桌子上的某个地方。 当有人通过手动输入跳到联系页面时,会发生什么?
无论如何,如果您丢失了ISBN,只需将其输出为隐藏表单输入即可。 然后,当他们在购物车页面上提交表单时,它将与之一起发布。 您还可以使用$ _REQUEST允许发布和获取变量。
mysql_query被折价了。 您需要停止使用它,pdo或mysqli是您的选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.