Thread: Resolved PHP complex WHERE statement
View Single Post
Old 07-05-2011, 10:07 AM   PM User | #2
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,227
Thanks: 2
Thanked 189 Times in 187 Posts
djm0219 is on a distinguished road
Assuming you want any of your like conditions to be satisfied only if visible is 1 then wrap the logic you already have in parenthesis then add the visible = 1 as shown below.

PHP Code:
$response mysql_query("SELECT * FROM  `tData`  
    WHERE (word1 LIKE '%"
.$q."%'
    OR conj LIKE '%"
.$q."%' 
    OR word2 LIKE '%"
.$q."%'
    OR username LIKE '%"
.$q."%'
    OR lineID LIKE '%"
.$q."%')
    AND visible = 1
    ORDER BY `lineID` DESC LIMIT 0 , 10"
); 
__________________
Dave .... HostMonster for all of your hosting needs
djm0219 is offline   Reply With Quote