>> I have a TBL of users and I have created a search screen where you can
type in 
>> first or last name and it will retrieve the appropriate records. Here is
the statement:

>> "Select * from STUDENTS WHERE FName LIKE '%" .$_REQUEST['searchit']. "%' 
>> OR LName LIKE '%" . $_REQUEST['searchit']. "%' OR  idStudent LIKE '%"
>> .$_REQUEST['searchit']. "%'"


I'm assuming you're using PHP with MySQL because of the reference to
$_REQUEST and using . To concatenate.

It could be a case, whitespace or data type issue.

Try using:

"SELECT 
        * 
FROM
        students 
WHERE 
        lower( trim( FName ) ) LIKE '%" . strtolower( trim(
$_REQUEST['searchit'] ) ) . "%' 
OR 
        lower( trim( LName ) ) LIKE '%" . strtolower( trim(
$_REQUEST['searchit'] ) ) . "%' 
OR 
        lower( trim( idStudent ) ) LIKE '%". strtolower( trim(
$_REQUEST['searchit'] ) ) . "%'"


If your idStudent field is a numeric data type then you need to do an
equality comparision rather than a like...

"SELECT 
        * 
FROM
        students 
WHERE 
        lower( trim( FName ) ) LIKE '%" . strtolower( trim(
$_REQUEST['searchit'] ) ) . "%' 
OR 
        lower( trim( LName ) ) LIKE '%" . strtolower( trim(
$_REQUEST['searchit'] ) ) . "%' 
OR 
        idStudent = ". $_REQUEST['searchit'] 


If this doesn't work please post the table structure (describe tablename)
and your PHP script.

Cheers

Dean


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to