Jump to content

I Need A Coding Expert To Look At This


techmistress

Recommended Posts

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? :whistle::pirate::P 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>

Link to comment
Share on other sites

Guest EverythingWeb

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...