PHP购物车问题 [英] PHP Shopping Cart Problem

查看:33
本文介绍了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.

问题:

将产品添加到购物车后,用户会被带到结帐"页面,在那里他们可以编辑他们想要的商品数量.

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.

如何将这些带有已编辑/新值的项目放入 PHP 变量中,然后更新数据库中的相应条目?

How can I get these items with their edited/new values into a PHP variable, and then update the corresponding entries in the database?

有问题的页面是:

但要实际查看结帐"页面中的内容,您需要访问:

But to actually see stuff in the "checkout" page, you'll need to visit:

http://www.com.au/.php 并点击一些价格,然后点击表格上方的下订单"链接.

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.

推荐答案

如果我没理解错,你只需要添加一个输入变量.

If I understand you correctly, you just need to add a input variable.

<tr>
    <td>Cool Item</td>
    <td><input type='text' name='items[<?=$product_id;?>]' value='1' /></td>
</tr>

然后检查 $_POST['items'] 数组.

Then check the $_POST['items'] array.

foreach($_POST['items'] as $product_ID=>$quanity) {
    proccessItem($product_ID, $quanity);
}

这篇关于PHP购物车问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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