If same product in multiple rows and contain invoice number

hi all

i am showing results of purchases made by customer.

$qry = "select * from cart table"
$result = mysql_query($qry);
while($row=mysql_fetch_array($result)
{
    echo $row['user_name'];
    echo $row['product_name'];
    echo $row['price'];
    echo $row['quantity'];
    echo $row['invoice_number'];
    echo $row['status'];

}


In the above screeshot
the product “samsung s4 white” is contained in two rows

but one row has invoice number and other row does not have invoice number.

to make it more clear what i am trying to create :

i am querying from the cart table

a customer came and added product to cart so it got added to cart table only.

the customer didnt completed order so there is no value for invoice_number in some rows.

then again after one day he came to website

he added two products and one product has same name that he added before one day.

but this time he completed order and the invoice number got updated in the invoice field.

so there becomes two rows

one with invoice number and other without invoice number but product name remain same in them.

so if he purchased the same product product after one day then both the first entry and second entry of same product name should be removed from cart table.

also the other row which is associated with same invoice number should also be removed.

so thats what i am trying to create.

now can anybody tell me what should be added to my above code ??

if should i write in the if condition to check that similar product has been bought with invoice number so that i can remove those entries from cart table

if(invoice number contained same product) 
{
    
}

vineet

Wouldn’t it be better to remove the incomplete order details from the cart table at some point, rather than trying to figure out how to leave them out of the display? I’m sure I’ve read a similar thread on here recently about when to decide to purge cart entries that haven’t been completed - have a read back down the board for a couple of weeks.

Also, if the customer comes back the next day and the stuff is still in his cart, shouldn’t it show that it’s still there and either he won’t add the same product, or when he adds the same product, he’ll have two in the card? So when he processes the order, he can see it’s remembered the previous one and reduce the quantity to get the correct number.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.