View Full Version : if same product in multiple rows and contain invoice number

08-13-2016, 09:49 AM
hi all

i am showing results of purchases made by customer.

$qry = "select * from mytable"
$result = mysql_query($qry);
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.

So what i want is

if same product name is contained in two rows and one of them has invoice number
then these both rows should not get display and also the row containing same invoice number should not display.

means all 3 rows should be omitted.

so how to check that same product product is in another row but that row also contains invoice number.

so what should i write in the "if condition"

if(invoice number contained same product)



08-13-2016, 05:38 PM
What row? In the code there are 6 rows for each row in the image where there are three rows, if "means all 3 rows should be omitted" you have nothing left, I don't think this is what you mean. And this is probably the root of the problem. If you cannot even explain clearly in words what you're after, it will be very hard to code it.

Now, according to your written word rules, and looking at the picture, that means there would be nothing there. If we ignore "means all 3 rows should be omitted", and read only the rest, that means that only the Apple iPhone would remain.

But what I think you mean, and what makes most sense is that only the duplicate item that also has no invoice number should be removed, leaving the iPhone and only the one Samsung device with the invoice # (total of two items left for the whole image once done). Now that's just for the example picture. I think you also want it so that IF there happened to be a duplicate item with the same invoice number, that should be removed as well, but there's nothing in your image that corresponds to that case. So that rule would make no changes.

Is that right?

08-14-2016, 02:47 AM
hi john

in the screenshot

this is my cart table

a customer added "samsung s4 white" to cart but didnt completed the order so it remained only in cart table without invoice number.

then after one day he again visited website and added 2 products in cart
one is "apple iphone" and second is "samsung s4 white" and then completed order so the row got a invoice number.

this means customer didnt bought the samsung phone first day but he bought next day.

so i want to remove the entry of earlier added same "samsung phone" if this product has been bought next day.

also on the same invoice he purchased "apple iphone" also so i want to omitt that full entry also because its associated with same invoice number.

hope that makes more clear what i am trying to do