PHP购物车问题
好的,我有一个购物车问题。
我决定推出自己的购物车,这比我预期的要容易得多。但是,我遇到了一个问题,我一生都无法弄清楚下一步该做什么。
问题:
将产品添加到购物车后,用户会被带到“结账”页面,他们可以在其中编辑所需商品的数量。
这些项目显示在表格中。
如何将这些项目及其编辑/新值放入 PHP 变量中,然后更新数据库中的相应条目?
有问题的页面是:
但要实际查看“结帐”页面中的内容,您需要访问:
http ://www.com.au/.php 并单击几个价格,然后单击表格上方的“下订单”链接。
任何帮助/建议将不胜感激。
Okay, so I have a shopping cart problem.
I've decided to roll out my own cart, which is alot easier than I had expected. BUT, I've run into a problem and cannot for the life of me figure out what to do next.
The problem:
After adding products to the cart, the user is taken to a "checkout" page, where they edit the quantities of the items they want.
These items are displayed in a table.
How can I get these items with their edited/new values into a PHP variable, and then update the corresponding entries in the database?
The page in question is:
But to actually see stuff in the "checkout" page, you'll need to visit:
http://www.com.au/.php and click on a few prices, and then click "Place Order" link just above the table.
Any help/advice at all would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我理解正确的话,你只需要添加一个输入变量。
然后检查 $_POST['items'] 数组。
If I understand you correctly, you just need to add a input variable.
Then check the $_POST['items'] array.
您将需要使用发布到页面上的表单来更改数据库中的值。如果您不希望页面在更新时重新加载,另一种选择是使用 Ajax 请求。
我想说,在这种情况下,您需要向数量框中添加一个“从购物车中删除”按钮和一个 onkeyup 事件,然后通过 Ajax 进行处理。
You will need to use a form that post onto the page to change the values in the database. Another option would be to use an Ajax request if you do not want the page to reload on update.
I would say in this instance you would want add a remove from cart button and a onkeyup event to your quantity box that would then be handled through Ajax.
您的问题不清楚,但我回答是因为您感谢任何帮助。 :-)
你正在使用会话吗?
保留所选项目,
创建一个会话数组,用于在用户编辑其购物车时
更新该会话数组。显示该数组中的项目。最后,当他从该会话数组中将发布数据签入数据库时。
我在网站上发现错误
警告:第 55 行 E:\web\onestopf\checkout.php 中为 foreach() 提供的参数无效
然后该行计数现在为 10,20,23。 10、20、30 会更好:-)
Your question is not clear, but am answering because you appreciate any help. :-)
Are you using session.
create a session array for keep the selected items
when ever user edit his cart update thats session array.
show items from that array. at last when he check out post data into db from this session array.
i found an error on website
Warning: Invalid argument supplied for foreach() in E:\web\onestopf\checkout.php on line 55
Then on that row count now its 10,20,23. 10,20,30 will be better :-)