如何显示客户购买的所有产品(产品名称,product_qty.etc)?

时间:2014-02-13 09:52:29

标签: php mysql arrays

我正在创建一个用于论文目的的在线订购系统。 我在显示客户购买的所有产品时遇到了问题。

<?php
    if(isset($_SESSION['user_id'])){
        $id = $_SESSION['user_id'];
        $sql_cus ="SELECT c.lname,c.fname,c.email,c.c_num,c.homeadd,c.barangay,c.city,c.province,
                    der.code,der.date,od.orderid
                    FROM customer c
                    LEFT JOIN orders der
                    ON der.customer_id=c.id
                    LEFT JOIN order_details od
                    ON der.id=od.orderid
                    LEFT JOIN products p
                    ON od.productid = p.id
                    WHERE c.id ='$id' 
                    LIMIT 1";
        $result_cus = mysql_query($sql_cus,$connection);
        check_if_connected($result_cus);
        $count_cus = mysql_num_rows($result_cus);
        if($count_cus>0){
            while($row=mysql_fetch_array($result_cus)){
                $id = $row['id'];
                $lname = $row['lname'];
                $fname = $row['fname'];
                $email = $row['email'];
                $c_num = $row['c_num'];
                $home = $row['homeadd'];
                $barangay = $row['barangay'];
                $city = $row['city'];
                $province = $row['province'];
                $orderid = $row['orderid'];
                $code = $row['code'];
                $date = $row['date'];
            }
        }
        else{
            echo "Wala";
        }
    }else{

    }
?>
Order No.: <?php echo $code;?><br /><br />
Order Date: <?php echo $date;?><br /><br />
Delivered to:<br /><br />
&nbsp;&nbsp;Name:  &nbsp;<?php echo $lname.", ".$fname;?><br />
&nbsp;&nbsp;Address: &nbsp;<?php echo $home." ".$barangay." ".$city.", ".$province;?><br />
&nbsp;&nbsp;Email:  &nbsp;<?php echo $email;?><br /><br />
<br />
Order Details<?php echo $orderid;?><br />

Sample that I want to display

有什么想法吗?或者有人可以帮我这个吗?

提前致谢

0 个答案:

没有答案