Hey gang, I have a user table with a column named state_id and I have a bunch of people from multiple states registered and all of their information stored in this table. Also, when a visitor logs in to the site I have that users state_id in a session variable named $sessioin_state_id.
The sql query below works, but it searches the entire table and results in all the users who meet the search criteria regardless of their state. So if someone searches for "Smith" they get all of the Smiths from all of the states. Now I want to use the users $session_state_id in the query below so that only the Smiths from users state are returned. Is this possible? I tried adding "state_id=$session_state_i
d AND " after the WHERE, but I couldn't get it to work. Any suggestions?
$sql = "SELECT username, first_name, middle_name, last_name FROM users WHERE MATCH(first_name, middle_name, last_name) AGAINST ('%$searchstring%' IN BOOLEAN MODE)";