How would I pull everyone from the table that have bag and wallet as gift. In this instance I would expect it to return katy (once only) because katy has wallet and bag as gift.
I would take a query and then use an if statement to check if any of the returned values have the same name. It really depends on how you have your table set up. If the types of gifts are static you could set the table up more effieciently to just list something like: id, Name, gift1, gift2, etc... 1, Katy, Y, Y 2,Matt, N, Y The way you have it setup right now would make a more complicated query because you want to check if two different rows of the table contain values. You could try something like: $query = "Select * FROM table WHERE gift ='bag' OR gift='wallet' "; PHP: Those results could then go into an array and you could loop through to check if the same name comes up for both types of gift. Probably a nested foreach loop. So with your mysql_fetch_array you would set all the results that return bag to a bag array with a name and all the wallet results to another. Then go do a foreach to check the bag array for names. Take the current name for the bags array and nest another foreach to use that name and check if it occurs in the wallet array. If it does then have that name added to a results array which will give you the final names for people with bags and wallets. I know that is a ton of code for such a simple request but it is the best way I can think to do it. However there are many people on this forum much more experienced with php and mysql than I am so they might know a more 'direct' way to go about this through a more slective query.
The actual table structure is a lot more complex and contains a lot more variables. I would have to create a lot of loops inside on another. There should be a way to do it with one query... Thanks for the help. I will probably do it that way unless someone shows me how to do it with a query.