Restricted Search

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Base
Forum Newbie
Posts: 13
Joined: Thu May 27, 2004 6:12 am

Restricted Search

Post by Base »

I am coding a search function for a website. The idea is, the user can enter a search input, but can only search results in their company. Unfortunately, the search doesn't restrict the user's search. This is my code:

Code: Select all

$query = "SELECT 
			user_id, 
			CONCAT(lastname, ', ', firstname) AS lastname, 
			email, 
			company, 
			position, 
			results, 
			DATE_FORMAT(timestamp, '%m/%d/%y'), 
			timestamp  
		  FROM dbci_user_surveys 
		  WHERE user_id LIKE '%$search%'
		  OR firstname LIKE '%$search%'
		  OR lastname LIKE '%$search%'
		  OR email LIKE '%$search%'
		  OR position LIKE '%$search%'
		  AND company = '$coco'";
$coco = company variable
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: use parens..
Base
Forum Newbie
Posts: 13
Joined: Thu May 27, 2004 6:12 am

Post by Base »

Its not working. Any other suggestions, preferably examples.

Thanks . . .
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what did you try?
Base
Forum Newbie
Posts: 13
Joined: Thu May 27, 2004 6:12 am

Post by Base »

I've already deleted what I tried and it will take me a while to redo it. I'm running out of time and I need help asap.
Post Reply