- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 php 新手,所以请原谅我的知识不足。我正在开发一个简单的购物车。我将屏幕分为三个 framset
。左侧是一个 imagemap
,用户可以在其中单击所需的项目。 topRight
是一个 php
页面,它检索并在表格中显示在 leftFrame
中单击的项目的详细信息。该表的最后一个单元格有一个 textfield
和一个用于提交订单的 button
。bottomRight
框架的目标是显示购物车,向用户显示已经选择了多少产品。我的问题是到目前为止我只能显示当前提交的订单。换句话说,我只显示 topRigt
框架中“订购”的最后一项的详细信息。我怎样才能继续添加第二个项目,而不是替换它?
这是topLeft
<html>
<head>
<title>Top Right</title>
<style type="text/css">
<!--
@import url("style.css");
-->
</style>
</head>
<body bgcolor = "#E0E6F8">
<h2>ITEMS</h2>
<?php
session_start();
// get the id from the left frame
$id = $_GET['var'];
// variable to connect to db
$user_name = "name";
$password = "password";
$server = "server";
$link = new mysqli($server,$user_name,$password,'poti');
if(!$link)
die("Could not connect to databse");
$result = $link->query("SELECT * FROM products WHERE product_id = '$id';");
while($row = $result->fetch_array())
{
$id = $row['product_id'];
$name = $row['product_name'];
$unit_price = $row['unit_price'];
$unit_quantity = $row['unit_quantity'];
$in_stock = $row['in_stock'];
$arrayName = array('id' => $id, 'name' => $name);
// store values in session
$_SESSION['cart'] = $arrayName;
// display details in a table (code needs to be refactored)
if(!empty($row)){
print "";
print "<form method='post' name='add' id='add' action='' target=''>";
print "<table id='hor-minimalist-a' border = '0' width = '100%'>";
print "<thead>
<tr>
<th scope='col'>ID</th>
<th scope='col'>Name</th>
<th scope='col'>Price</th>
<th scope='col'>QTY</th>
<th scope='col'>In Stock</th>
<th scope='col'>Order</th>
</tr>
</thead>";
print "<tr>\n";
print "<td>";
print($id);
print "</td>";
print "<td>";
print($name);
print "</td>";
print "<td>";
print($unit_price);
print "</td>";
print "<td>";
print($unit_quantity);
print "</td>";
print "<td>";
print($in_stock);
print "</td>";
print "<td>
<input type='text' name='qty_ordered' size='4'><input type='submit' name='submit' value='Submit' onclick='checkQty()'>
</td>";
print "</tr>";
}
print"</table>";
print "</form>";
}
?>
<script type="text/javascript">
function checkQty()
{
if(document.add.qty_ordered.value > 0 && document.add.qty_ordered.value <= 20)
{
document.add.action = "bottomRight.php";
document.add.target = "BottomRight";
document.add.submit();
}
else
{
//document.add.action = "topRight.php";
//document.add.target = "TopRight";
alert("Quantity must be between 1 and 20, please enter a value between 1 to 20");
//document.add.submit();
}
}
</script>
</body>
</html>
对于bottomRight
:
<html>
<head>
<title>Bottom Right</title>
<style type="text/css">
<!--
@import url("style.css");
-->
</style>
</head>
<body>
<h2>Shopping Cart</h2>
<?php
session_start();
// doing this I keep on displaying only the last item "ordered"
if (isset($_POST['submit'])===true) {
if(isset($_SESSION['cart'])===true) {
$array = array($_SESSION['cart']);
print_r($array);
// not working
/*foreach($array as $a)
{
echo "<table><tr>";
echo "<td width='150px'><span style='color:white'>" . $a['id'] ."</span></td>";
echo "</tr></table>";}*/
}
}
?>
</body>
</html>
最佳答案
在 youtube 上查看 Adam Khoury 提供的视频教程。他使用了 mysql_*
(我知道它已被弃用)函数,但您可以使用自己的代码来解决问题。该视频仅供您引用。
这是 youtube 播放列表链接:https://www.youtube.com/playlist?list=PL442E340A42191003
这里是解决您查询的具体视频链接:https://www.youtube.com/watch?v=WXqbQy9fOp8
希望对你有帮助。
关于javascript - 将商品添加到购物车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23147942/
我们都在流行的网站上看到,购物车图标的右上角有一个小图标!我必须在我的 ASP .NET 网页中使用类似的东西。 如何让这个图标位于购物车图标的右上角.. 购物车的图标是一个普通的 bootstrap
Closed. This question does not meet Stack Overflow guidelines 。它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 Stack Ov
可以使用 REST 架构约束来实现购物车吗? 我想把我的问题集中在 session 状态上。在实现购物车的典型 MVC 应用程序中,很可能 session 对象将在 session 中管理,购物车作为
我的网上商店使用自己的模板,但在我的网站上我使用货币欧元而不是美元。哪里可以编辑啊。 http://i50.tinypic.com/67rvhc.png 最佳答案 进入系统>配置。 然后在“通用”>“
我想在我的门户中使用购物车。我可以获得 jquery 的购物车插件吗? 格纳尼亚尔·祖贝尔 最佳答案 http://simplecartjs.com/不是 JQuery,但如果 PayPal 或 Go
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 4年前关闭。 Improve this questi
我正在尝试将产品添加到我的购物车。 我收到一条错误消息: 警告:为 foreach() 提供的参数无效 它告诉我以下代码出现错误: function isInCart($id) { if (!empt
我目前正在使用 PHP 开发购物车,我正在尝试弄清楚如何使用我编写的代码将商品添加到购物车本身。我的数据库中的项目显示正确,但只有 $item 下的最后一个数组被添加到购物车。以下显示项目。 $res
在我的laravel购物车上,我创建了一个delete函数,使用json或dd函数进行测试时似乎还可以,但是尝试返回路线购物车 View Route [cart] not defined.时,这是一个
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
将相同的产品添加到购物车时,它正在添加新行,但如果相同的产品 ID 已在购物车中,则需要更新数量。 我需要它与数量更新保持一致。 最佳答案 您需要覆盖 app/code/core/Mage/Sales
你好, 我正在创建一个用于培训目的的 PHP 商店。我希望用户能够查看他最后下的订单 - 但我很难意识到这一点。 我的数据库中有这些表: 客户( child 、姓名、地址...) 产品(pid、pro
我正在考虑建立一个迷你购物网站。不涉及支付方式,只是显示和维护的所选产品的总数。这将由商店中的一个人操作以进行和监控销售。 概念是:产品应该在页面中显示为大图像,通过点击它们我将它们存储在购物车中。然
我有以下产品和购物车表格: //产品表 Products: id | Product_value ----------------------- 1 | Product
我尝试使用 php ang mysql 在 google 中搜索购物车中的代码。当我单击“添加到购物车”按钮时,我的 cart.php 中没有显示任何内容。请帮助我。 这是我的产品.php ">ADD
我正在为摄影业务创建 PHP 购物车。这是我尝试的第一个电子商务网站(新手) 我已成功将产品添加到购物车(存储在 session 中)(产品:打印品、 key 圈、磁铁等) 但是我还需要将 image
变量被添加到从另一个页面传递的 session 数组 此处为详细信息页面 string(4) "3911" [1]=> string(4) "5005" [2]=> NULL [3]=> strin
我的模型中设置了以下核心数据关系。 类别 -> 产品 -> 购物车产品 1)) { // handle error } else if (![cartProducts count]) {
我已经根据示例实现了jQuery的购物卡:http://jsfiddle.net/RR6z5/1/ 但是有一个小错误。当我将一个元素从产品拖到购物卡,然后无拖放,我从购物卡拖到产品时,产品中的原始元素
大家好,就 css 和 javascript 而言,我是个新手。我正在使用的新主题是让我的 paypal minicart 显示在内容下方,因此您不能单击它,也不能从中删除内容,但您可以看到购物车稍微
我是一名优秀的程序员,十分优秀!