techmistress Posted February 3, 2008 Share Posted February 3, 2008 Of course it isn't working quite as I wanted! In the admin, when viewing a particular order, I want to add a section that says: "Other orders by this Customer" and list all of the orders associated with the customer who made this particular order. I used the below code, but it shows all of the orders in the database. Who can figure it out for me? Please, please, pleeeaaase? Yaaaay, thanks!! <td colspan="2" class="copyText"> <?php $orders = $db->select("SELECT CubeCart_order_sum.customer_id, CubeCart_order_sum.status, CubeCart_order_sum.cart_order_id, CubeCart_order_sum.time, CubeCart_order_inv.cart_order_id FROM CubeCart_order_sum, CubeCart_order_inv WHERE CubeCart_order_sum.cart_order_id = CubeCart_order_inv.cart_order_id ORDER BY `time` DESC"); if($orders == TRUE){ for($i=0; $i<count($orders);$i++){ ?> <a href="order.php?cart_order_id=<?php echo $orders[$i]['cart_order_id']; ?>" class="txtLink"><?php echo $orders[$i]['cart_order_id']; ?></a> | <?php } } else { ?> No Other Orders <?php } ?> </td> Quote Link to comment Share on other sites More sharing options...
Guest EverythingWeb Posted February 3, 2008 Share Posted February 3, 2008 WHERE CubeCart_order_sum.cart_order_id = CubeCart_order_inv.cart_order_id This is the problem as you're selecting records where order_id is equal to order_id, which of course means every order! You'll need to change that second part to the variable that holds the current customers id, something like WHERE CubeCart_order_sum.cart_order_id = '.$customerID.' where $customerID is the name of a variable that holds the customer_id of the current order, which you'll need to get the correct variable name for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.