alright, I've been banging my head against this query for the past couple of days. Here's the deal, I hope I don't confuse you too much trying to explain this. I have 3 tables(listed below). Table 1 has general site login crap, table2 has application specific info(there will be more of these later), and table3 has information that has been used already.

Code:

table1:
email
password
enddate

table2:
email
catagory
code

table3
email
code

Every email in table2 will be in table1, but not neccessarily the other way around. Table3 is organized so after a user selects an item, that item is populated in table3 with the user's email and the code of the product selected.

Example:joe@blah.com is signed up for the app, so he has an entry there. He has already selected several codes, so he has a few entries in table3. The tables might look something like this now:

Using this, I'm hoping to display table2 items who's catagory matches the user's AND who's code is not listed in table3 next to the user's email. So, if joe were logged in, it would display items:bill@blah.com cat1 333333george@blah.com cat1 666666

This is what I've got right now. I know the third statement( $query .= "AND '$email'!=`$table2`.email "; ) is one of the problems. I'm not even sure if it is possible with this setup, so if need be, I'd even be willing to reorganize the tables...just keep in mind that down the road other apps will be added, and they will get their own table2 and table3.

Code:

...run code to get logged in user's information and set to $email, $category, and $code...