Reputation: 15
i use the following statement but it does not working properly.
$query = "select * from employee where status ='Active' and employee_id! ='".$data['employee_id']."') and (first_name like '$data%' or last_name like '$data%' or batch like '$data%' or job_title like '$data%' or company like '$data%' ORDER BY first_name";
$result = mysql_query($query);
Like i need to fetch all result but not employee_id=5; but i get the employee_id=5 result;is there any issue in query and other simplest way to use this query
Upvotes: 0
Views: 61
Reputation: 197
in your code $data['employee_id'] and like '$data% use both same variable you need to change $data for search value. it is overwrite.
do this and check
Upvotes: 0
Reputation: 576
Try this out:
$query = "select * from employee where status ='Active' and employee_id !='".$data['employee_id']."' and (first_name like '$data%' or last_name like '$data%' or batch like '$data%' or job_title like '$data%' or company like '$data%') ORDER BY first_name";
$result = mysql_query($query);
Upvotes: 0
Reputation: 2509
Remove the space after !
mark
Like this
where status ='Active' and employee_id !='".$data['employee_id']."')
Check this link to learn about operator http://php.net/manual/en/language.operators.comparison.php
Note:mysql is depricated learn Mysqli_ function or PDO or both
for Mysqli_ fucntion check this link http://php.net/manual/en/book.mysqli.php For PDO Check this link http://php.net/manual/en/book.pdo.php
Upvotes: 1