graham23s Posted July 24, 2008 Share Posted July 24, 2008 Hi Guys, in my code below i am trying to view what users have in there shopping carts! <?php case "orders-in-cart": ########################### # ORDERS IN CART ########################### // See what people have in there carts $q_sneak = "SELECT DISTINCT `customer_id`,`product_id` FROM `fcp_orders` GROUP BY `customer_id` DESC"; $r_sneak = mysql_query($q_sneak); // Loop them out while ($a_sneak = mysql_fetch_array($r_sneak)) { // Customers id $cus_id = $a_sneak['customer_id']; $cus_pt = $a_sneak['product_id']; // Query customer details $q_c = "SELECT * FROM `fcp_customers` WHERE `id`='$cus_id'"; $r_c = mysql_query($q_c); $a_c = mysql_fetch_array($r_c); // Vars $c_fn = $a_c['first_name']; $c_ln = $a_c['last_name']; // Query the product details $q_p = "SELECT * FROM `fcp_products` WHERE `id`='$cus_pt'"; $r_p = mysql_query($q_p); $a_p = mysql_fetch_array($r_p); // Vars $p_im = $a_p['product_thumbnail']; print("<table width='95%' border='1' cellpadding='5' cellspacing='0' />\n"); print("<tr>\n"); print("<td colspan='2' align='left' width=\"15%\">Customers Name:</td><td align=\"left\">$c_fn $c_ln</td>\n"); print("</tr>\n"); print("<tr>\n"); print("<td colspan='2' align='left' width=\"15%\">Products in cart:</td><td align=\"left\"><img src=\"products/thumbnails/$p_im\"></td>\n"); print("</tr>\n"); print("</table>\n"); print("<br />"); } break; ?> the way it is now it only shows 1 product image per customer (even if they have more than 1) can anyone see the problem? cheers Graham Link to comment https://forums.phpfreaks.com/topic/116482-querying-problem/ Share on other sites More sharing options...
Barand Posted July 24, 2008 Share Posted July 24, 2008 use ORDER BY, not GROUP BY Link to comment https://forums.phpfreaks.com/topic/116482-querying-problem/#findComment-599016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.