Hi everyone.
I have a database with various fields, inc. Name, Info, Gay. Name = name of entry, Info = information about the entry, Gay = 1 for gay entry 2 for non gay entry.
I have constructed click through pages that show results from the database, always showing the gay entries first. ie checking for a 1 in the database. So thats all good and works fine. Im now trying to do a site search.... fill in a word and what should happen is it checks if the word is in name or info, then checks for gay 1 or 2. As the example below. %$trimmed% = search word.
//$query = "select * from ghdata1 where ghdata1.name like '%$trimmed%' OR ghdata1.info like '%$trimmed%' AND ghdata1.gay LIKE '1' ORDER by rand()";
if its gay = 1 then it puts the results on screen, then, also in the results page it goes on to
//$query = "select * from ghdata1 where ghdata1.name like '%$trimmed%' OR ghdata1.info like '%$trimmed%' AND ghdata1.gay LIKE '2' ORDER by rand()";
where it now looks for the '2' non gay entries and puts them on screen also.
But whats happening is that for some reason some gay entries are being shown with the non gay entries, so its not checking the 1 or 2 properly.
Ive had a mess with the code and it works perfectly if I only check against either name or info, but doesnt work when I try to check against both..,
this works...
//$query = "select * from ghdata1 where ghdata1.name like '%$trimmed%' AND ghdata1.gay LIKE '1' ORDER by rand()";
so what am i doing wrong how do i get it to check name and info and then gay.
Hope that makes sence.
Thanks in advance
Lee