I have a strange occurence in a display and I'm wondering if it could have something to do with the formation of the query

I have a table that contains shopping cart line items (called dealer_item), stored as the dealer adds them to the cart.
This table currently holds 2 records (2 items in the shopping cart)
And a second table that contains the information about each item (called dealer_product)

When I am displaying the Cart, it is duplicating everything twice... In order as they should be, but the listing is displayed two times. So it shows that there are 4 items in the cart, while there are actually only 2.

Been messing with this for quite some time and hope that someone can see something that I'm missing.

Thanks in advance

$sql = "
  SELECT i.item_id, i.product_id, i.qty, i.price_each, i.back_color, i.person, p.product_name
  FROM dealer_item AS i, dealer_product as p
  WHERE i.cart_id='$cart_id'
  AND i.status='A'
  AND p.product_id=i.product_id
    <td class=\"bold12\">".$C_prod[$C_ct][6]."</td>
    <td class=\"bold12\">$".number_format($C_prod[$C_ct][3], 2, '.', '')."</td>
<form name=\"adjust\" action=\"dealer_cart.php\" method=\"POST\">
    <td class=\"bold12\">
      <input name=\"qty\" type=\"text\" size=\"2\" value=\"".$C_prod[$C_ct][2]."\" maxlength=\"2\">
    <td align=\"center\">
    <input type=\"hidden\" name=\"item\" value=\"".$C_prod[$C_ct][0]."\">
      <input type=\"hidden\" name=\"sub_act\" value=\"adjust\">
      <input type=\"image\" name=\"update\" src=\"images/cart_update.png\" width=\"80\" height=\"25\" border=\"0\" alt=\"Update Cart\">
    <td class=\"bold12\">$".number_format(($C_prod[$C_ct][3]*$C_prod[$C_ct][2]), 2, '.', '')."</td>
    <td align=\"center\">
      <form name=\"remove\" action=\"dealer_cart.php\" method=\"POST\">
      <input type=\"hidden\" name=\"item\" value=\"".$C_prod[$C_ct][0]."\">
      <input type=\"hidden\" name=\"sub_act\" value=\"remove\">
      <input type=\"image\" name=\"Remove from cart\" src=\"images/cart_remove.png\" width=\"80\" height=\"25\" border=\"0\" alt=\"Remove From Cart\">
    <td class=\"bold12\">".$C_prod[$C_ct][4]."</td>
    <td class=\"bold12\">".$C_prod[$C_ct][5]."</td>


if ($C_ct==0 && !isset($C_prod[$C_ct][0])){
  print "  <tr><td colspan=\"8\" align=\"center\"><p class=\"bold16\"><font color=\"#3366FF\">Your Shopping Cart is empty</font></p></td></tr>";

Strike that Question... I just realized what the issue was...

I had the product_id set as INT(5) in one table and VARCHAR(12) in the other one...

hard to store alphanumeric data in an INT field and then compare it to a VARCHAR field..

Sorry ...

Why the hell are you using all those escaped quotes. It makes for an unreadable mess.

Just use single quotes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.