search bar

search bar

jausonjauson Posts: 7Questions: 0Answers: 0
edited December 2011 in General
Helo, I have a problem, I limit the records by department, for example in my page the records shows only the IT department, but when I search a name in search bar for example I will search a name of employee in other department their record will show. how do i limit the search bar by department only? thanks a lot.

$sWhere = "WHERE department='$department'";
if ( $_GET['sSearch'] != "" )
{
$sWhere = "WHERE (";
for ( $i=0 ; $i

Replies

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    You need to add an AND condition to the WHERE after the column specific search has been built. Something like $sWhere .= " AND department='$department'"; - remember to add a condition for when $sWhere is empty though!

    Allan
  • jausonjauson Posts: 7Questions: 0Answers: 0
    I don't know where do i need to input the ADD OPERATOR.. can u show me where?

    $sWhere = "WHERE department='$department'";
    if ( $_GET['sSearch'] != "" )
    {
    $sWhere = "WHERE (";
    for ( $i=0 ; $i
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    Rather than doing it at the start of that code block, do it at the end.

    Allan
This discussion has been closed.