如何在while循环中将数组中的值添加到文本框中

时间:2015-03-13 15:50:07

标签: php arrays loops while-loop cart

我在购物车的循环中有产品,但是qty的值没有出现在每个文本框上都有这个错误。
注意 C:\ xampp \ htdocs \ ecommerce \ cart.php 中的数组到字符串转换 172 阵列

<?php 
    $total = 0;

    global $con; 

    $ip = getIp(); 

    $sel_price = "select * from cart where ip_add='$ip'";

    $run_price = mysqli_query($con, $sel_price); 

    while($p_price=mysqli_fetch_array($run_price)){

        $pro_id = $p_price['p_id']; 

        $pro_price = "select * from products where product_id='$pro_id'";

        $run_pro_price = mysqli_query($con,$pro_price); 

        while ($pp_price = mysqli_fetch_array($run_pro_price)){

        $product_price = array($pp_price['product_price']);

        $product_title = $pp_price['product_title'];

        $product_image = $pp_price['product_image']; 

        $single_price = $pp_price['product_price'];
        $single_price = number_format($single_price);
        $values = array_sum($product_price); 
        $total += $values;  


        $pro_qty = "select * from cart where p_id='$pro_id'";

        $run_pro_qty = mysqli_query($con,$pro_qty); 

        while ($pp_qty = mysqli_fetch_array($run_pro_qty)){

        $product_qty = array($pp_qty['qty']);

                ?>

                <tr align="center">
                    <td><input type="checkbox" name="remove[]" value="<?php echo $pro_id;?>"/></td>
                    <td><?php echo $product_title; ?><br>
                    <img src="admin_area/product_images/<?php echo $product_image;?>" width="60" height="60"/>
                    </td>
                    <td><input type="text" size="4" name="qty" value="<?php echo $product_qty;?>"/></td>
                    <td><?php echo "Php " . $single_price; ?></td>
                </tr>
    <?php } }?>

0 个答案:

没有答案