0

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
Douglas

<?php
$line_items=0;
$item_count=0;
$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
";
$result=mysql_query($sql);
$C_ct=0;
$cart_ship=0;
while($C_prod[$C_ct]=mysql_fetch_array($result)){
print"
  <tr>
    <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>
    <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>
</form>
    <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\">
      </form>
    </td>
    <td class=\"bold12\">".$C_prod[$C_ct][4]."</td>
    <td class=\"bold12\">".$C_prod[$C_ct][5]."</td>
  </tr>
";

++$line_items;
$item_count=$item_count+$C_prod[$C_ct][2];

++$C_ct;
}
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>";
}
?>
2
Contributors
2
Replies
6
Views
4 Years
Discussion Span
Last Post by iamthwee
0

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 ...

Edited by showman13

0

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

Just use single quotes.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.