Results 1 to 3 of 3

Thread: if same product in multiple rows and contain invoice number

  1. #1
    Join Date
    Nov 2011
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default if same product in multiple rows and contain invoice number

    hi all

    i am showing results of purchases made by customer.


    Code:
    $qry = "select * from mytable"
    $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'];
    
    }
    Click image for larger version. 

Name:	ct.jpg 
Views:	152 
Size:	17.5 KB 
ID:	5922
    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"

    Code:
    if(invoice number contained same product) 
    {
    	
    }
    vineet

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2011
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

    vineet

Similar Threads

  1. Replies: 1
    Last Post: 10-16-2011, 06:34 PM
  2. Replies: 9
    Last Post: 12-13-2009, 04:53 PM
  3. Replies: 7
    Last Post: 01-04-2009, 07:25 PM
  4. Is a number whole? and Is a number a multiple of x?
    By techno_race in forum JavaScript
    Replies: 17
    Last Post: 08-31-2008, 02:59 AM
  5. order by number of rows in anther table?
    By Jas in forum MySQL and other databases
    Replies: 5
    Last Post: 08-12-2008, 07:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •