Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用多维数组购物车会话将表单隐藏为有效订单_Php_Multidimensional Array_Hidden Field - Fatal编程技术网

Php 使用多维数组购物车会话将表单隐藏为有效订单

Php 使用多维数组购物车会话将表单隐藏为有效订单,php,multidimensional-array,hidden-field,Php,Multidimensional Array,Hidden Field,我尝试保存购物车数组以完成订单,然后从客户那里获取关于他的订单的日期。我做了一些东西,但效果不好,首先是在页面confirm_comanda.php上向我显示最后一个数组的数组日期,例如我在购物车会话3中的产品,正在给我最后一个数组产品的产品名称价格。只有数量显示得很好,最终价格称为totalComandPret // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item)

我尝试保存购物车数组以完成订单,然后从客户那里获取关于他的订单的日期。我做了一些东西,但效果不好,首先是在页面
confirm_comanda.php
上向我显示最后一个数组的数组日期,例如我在购物车会话3中的产品,正在给我最后一个数组产品的
产品名称
价格
。只有
数量
显示得很好,最终价格称为
totalComandPret

// Start the For Each loop
    $i = 0; 
    foreach ($_SESSION["cart_array"] as $each_item) { 
        $item_id = $each_item['item_id'];
        // start select query stmt
        $stmt = $con->prepare('SELECT id, product_name, price, size, details FROM products WHERE id = ? LIMIT 1');
        $stmt->bind_param('i', $item_id);
        $stmt->execute();
        $stmt->bind_result($idSelect, $product_name, $price, $size, $details);//variabla pe care o vrei inlocuita prin bind_Result in loc de get_Result
        while ($stmt->fetch())    {
           $idSelect;
           $product_name; // faci acelasi lucru fara $row 
           $price;    
           $size;
           $details;    
        }
        $stmt->free_result();
        // stoop select stmt    
        $pricetotal = $price * $each_item['quantity'];
        $cartTotal = $pricetotal + $cartTotal;
                // Create the product array variable
        $product_id_array .= "$item_id-".$each_item['quantity'].","; 
        // Dynamic table row assembly
        $cartOutput .= "<tr>";
        $cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="100" height="62" border="1" /></td>';
        $cartOutput .= '<td>' . $details . '</td>';
        $cartOutput .= '<td>' . $price . ' RON</td>';
        // How to split a query value into several mutiple rows for a select tag using explode() STAART SIZE
        $myArraySize = explode(' ',  $size);
        $cartOutput .= '<td><form action="cart.php" method="post"><select name="size">';
        foreach($myArraySize as $my_ArraySize)
        {
        $cartOutput .= '<option  value="'.$my_ArraySize.'">'.$my_ArraySize.'</option>';
        }
        $cartOutput .= '</select><input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" />buc
        <input name="adjustBtn' . $item_id . '" type="submit" value="change" />
        <input name="item_to_adjust" type="hidden" value="' . $item_id . '" />
        </form></td>';
        //STOP SIZE
        //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>';
        $cartOutput .= '<td><center>' . $pricetotal . ' RON</center></td>';
        $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>';
        $cartOutput .= '</tr>';
//启动For Each循环
$i=0;
foreach($\会话[“购物车数组”]作为$each项目){
$item_id=$each_item['item_id'];
//开始选择查询stmt
$stmt=$con->prepare('SELECT id,product_name,price,size,products的详细信息,其中id=?LIMIT 1');
$stmt->bind_参数('i',$item_id);
$stmt->execute();
$stmt->bind_result($idSelect,$product_name,$price,$size,$details);//variabla pe care o vrei inlocuita prin bind_result in loc de get_result
而($stmt->fetch()){
$idSelect;
$product_name;//faci acelasi lucru fara$行
$price;
$size;
$details;
}
$stmt->free_result();
//弯腰选择stmt
$pricetotal=$price*$每件物品['quantity'];
$cartTotal=$pricetotal+$cartTotal;
//创建产品数组变量
$product_id_array.=“$item_id-”$each_item['quantity']。”,“;
//动态表行组装
$cartOutput.=“”;
$cartOutput.='
'; $cartOutput.=''.$details'; $cartOutput.=''.$price.'RON'; //如何使用explode()stat SIZE将查询值拆分为一个select标记的多行 $myArraySize=爆炸(“”,$size); $cartOutput.=''; foreach($myArraySize为$my_ArraySize) { $cartOutput.=''.$my_ArraySize.''; } $cartOutput.='buc '; //停止大小 //$cartOutput.=''.$each_item['quantity'.'”; $cartOutput.=''.$pricetotal.'RON'; $cartOutput.=''; $cartOutput.='';
用于获取会话数组的隐藏表单日期来自购物车数组中选择的产品

$cofirmaComanda = '<form  action="cofirma_comanda.php" method="post">';
            $i=0;
            foreach ($_SESSION["cart_array"] as $each_item) { //start second forecach

            $cofirmaComanda .='
            <input name="prettotal[]"  type="hidden" value="'. $pricetotal .'">
            <input name="produseID[]"  type="hidden" value="'. $item_id .'">
            <input name="produseNume[]"  type="hidden" value="'. $product_name .'">
            <input name="size[]"  type="hidden" value="'. $my_ArraySize .'">
            <input name="cantitate[]"  type="hidden" value="' . $each_item['quantity'] .'">
            <input name="produse[]"  type="hidden" value="'. $item_id .'">;
            <input name="totalCOMANDApret[]"  type="hidden" value="'. $cartTotal .'">';
                } //close second foreach
            $cofirmaComanda .='<input type="submit" name="CofirmaComanda" value="cofirma_comandaTOW"></form>';  
        } 
$cofirmaComanda='';
$i=0;
foreach($_SESSION[“cart\u array”]作为$each item){//start second foreach
$cofirmaComanda.='
;
';
}//关闭第二个foreach
$cofirmaComanda.='';
} 
页面确认_comanda.php以使订单有效,并记录客户的账单日期和发货日期

$countArray = count($_SESSION['cart_array']);
for ($i=0; $i<$countArray; $i++) {
    $pretTotal = $_POST["prettotal"][$i];
    $PRODUSE = $_POST["produseID"][$i];
    $produseNume = $_POST["produseNume"][$i];
    $size = $_POST["size"][$i];
    $cantitate = $_POST["cantitate"][$i];
    $total = $_POST["totalCOMANDApret"][$i];
}
$countArray=count($\u会话['cart\u array']);
对于($i=0;$i)

我知道这是一个完整的代码,但我真的想解决这个问题,脚本的一部分是从一个在线课程中提取的,但他们使用了paypal,我更改了它,因为我想使它更简单

请任何人?能给我一个答案吗?对不起,请给我一个答案?能给我一个答案吗?对不起,重复发布吗
<form action="confirma_comanda2.php"   method="post">
<tr><td>nume: <input name="nume_client" type="text"></td></tr>

<tr><td>email: <input name="email_client" type="email"></td></tr>
<tr><td>telefon: <input name="telefon_client" type="number"></td></tr>
<tr><td>judet: <select name="judet_client">
<option value="Arges">Arges</option>
<option value="Arad">Arad</option>
<option value="Timis">Timis</option>
</select></td></tr>
<tr><td>adresa: <input name="adresa_client" type="text"></td></tr>
<?php
for ($i=0; $i<$countArray; $i++) {
    $confirmForm =' <input type="hidden" name="prettotal" value=" echo '.$pretTotal[$i].'">
<input type="hidden" name="produse" value=" echo '.$PRODUSE.'">
<input type="hidden" name="produseNume" value=" echo'.$produseNume.'">
<input type="hidden" name="cantitate" value=" echo'.$cantitate.'">
<input type="hidden" name="size" value=" echo'.$size.'">
<input type="hidden" name="totalComanda" value="'.$total.'">';
}
?> 
<tr><td><input  type="submit" name="sumbitDateClienti" value="Trimite Comanda"></td><td><input type="button" onClick="location.href='index.php';" value="Inapoi la Cumparaturi">