Php 如何在数据库上提交签出产品详细信息?
我在电子商务网站上工作,一切都很好。现在我在结账页面上。客户首先填写账单明细,然后下订单 我正在数据库中获取账单详细信息,但没有获取订单详细信息 checkout.phpPhp 如何在数据库上提交签出产品详细信息?,php,jquery,html,Php,Jquery,Html,我在电子商务网站上工作,一切都很好。现在我在结账页面上。客户首先填写账单明细,然后下订单 我正在数据库中获取账单详细信息,但没有获取订单详细信息 checkout.php <form action="process.php" method="Post"> <!--bill details field--> //fields <!--end bill details field--> <!--shipping d
<form action="process.php" method="Post">
<!--bill details field-->
//fields
<!--end bill details field-->
<!--shipping detials filed-->
//Shipping details
<!--end shipping detials filed-->
<!--order detials are(Session is working perfectly)-->
if(!empty($_SESSION['product_cart'])):
foreach($_SESSION['product_cart'] as $key=>$product):
?>
<li>
<div class="order-list">
<img src="admin/images/products/<?php echo $product['p_images'];?>">
<?php echo $product['p_brandname'];?>
<div class="circle-qty"><?php echo $product['quantity'];?></div>
<span>$<?php echo $product['p_total'];?></span>
<input type="hidden" name="o_product_name[]" value="<?php echo $product['p_brandname'];?>">
<input type="hidden" name="o_product_qty[]" value="<?php echo $product['quantity'];?>">
<input type="hidden" name="o_product_single_cost[]" value="<?php echo $product['p_currentprice'];?>">
<input type="hidden" name="o_product_totalcost[]" value="<?php echo $product['p_total'];?>">
</div>
</li>
<?php $total_amount[]= $product['p_total'];//getting all the product price and assigning to array for total amount?>
<?php endforeach;?>
<li class="checkout-total"><div><h2>Total</h2><span>$<?php echo array_sum($total_amount);?></span></div></li>
<?php endif;?>
</form>
echo $o_product_name=$conn->real_escape_string(trim($_POST['o_product_name']));
echo $o_product_qty=$conn->real_escape_string(trim($_POST['o_product_qty']));
echo $o_product_single_cost=$conn->real_escape_string(trim($_POST['o_product_single_cost']));
echo $o_product_totalcost=$conn->real_escape_string(trim($_for each_product_totalcost']));
Process.php
<form action="process.php" method="Post">
<!--bill details field-->
//fields
<!--end bill details field-->
<!--shipping detials filed-->
//Shipping details
<!--end shipping detials filed-->
<!--order detials are(Session is working perfectly)-->
if(!empty($_SESSION['product_cart'])):
foreach($_SESSION['product_cart'] as $key=>$product):
?>
<li>
<div class="order-list">
<img src="admin/images/products/<?php echo $product['p_images'];?>">
<?php echo $product['p_brandname'];?>
<div class="circle-qty"><?php echo $product['quantity'];?></div>
<span>$<?php echo $product['p_total'];?></span>
<input type="hidden" name="o_product_name[]" value="<?php echo $product['p_brandname'];?>">
<input type="hidden" name="o_product_qty[]" value="<?php echo $product['quantity'];?>">
<input type="hidden" name="o_product_single_cost[]" value="<?php echo $product['p_currentprice'];?>">
<input type="hidden" name="o_product_totalcost[]" value="<?php echo $product['p_total'];?>">
</div>
</li>
<?php $total_amount[]= $product['p_total'];//getting all the product price and assigning to array for total amount?>
<?php endforeach;?>
<li class="checkout-total"><div><h2>Total</h2><span>$<?php echo array_sum($total_amount);?></span></div></li>
<?php endif;?>
</form>
echo $o_product_name=$conn->real_escape_string(trim($_POST['o_product_name']));
echo $o_product_qty=$conn->real_escape_string(trim($_POST['o_product_qty']));
echo $o_product_single_cost=$conn->real_escape_string(trim($_POST['o_product_single_cost']));
echo $o_product_totalcost=$conn->real_escape_string(trim($_for each_product_totalcost']));
我试图显示该值,但不起作用。即使我尝试使用内爆函数,但也不起作用
foreach($o_product_name as $key => $value)
{
echo $key." has the value". $value;
}
//second tried
$string=implode(",",$o_product_name);
echo $string;
你能帮我一下吗?
$\u POST['o\u product\u name']
是一个数组。不能在修剪函数中传递数组。在process.php文件中,需要循环遍历$\u POST数组
foreach($_POST['o_product_name'] as $key=>$value)
{
echo $o_product_name=$conn->real_escape_string(trim($_POST['o_product_name'][$key]));
}
另一个也一样。请检查语法错误,因为我没有测试代码,但它应该可以正常工作
谢谢。在process.php中,不能在trim()方法中使用数组
因为给定的参数是数组,而不是预期的字符串。谢谢,它对我有用。