> Thanks - but did not work...here is the information you > requested. In looking at this please remember that, for > example, there are lots of smith records in the data, but > only one with the first name allen....and there are lots of > sarah records in the data but only one with the last name > ellis...it will find sarah ellis, but not allen smith. But if > I run that join statement listed in my original post, it will > find both.... > > Anyway following is the info... > > TABLE STRUCTURE: > idStudent int PRIMARYKEY AUTO INC > FName varchar(50) > LName varchar(50) > Address varchar(50) > City varchar(50) > State char(2) > Zip varchar(10) > Phone varchar(20) > Email varchar(255) > DOB datetime > Gender int > Deleted int > > PHP SCRIPT: > /* Performing SQL query */ > $GETSTUDENT_query = "Select * from STUDENTS WHERE > lower(Trim(FName)) LIKE '%" .strtolower(trim($_REQUEST['searchit'])). "%' OR > lower(trim(LName)) LIKE '%" .strtolower(trim($_REQUEST['searchit'])). "%' OR idStudent > LIKE '%" .$_REQUEST['searchit']. "%'"; > > $GETSTUDENT_result = mysql_query($GETSTUDENT_query) or > die("Query failed : " > . mysql_error()); > > $GETSTUDENT_num_results = mysql_num_rows($GETSTUDENT_result); > > if ($GETSTUDENT_num_results == 0) > { > echo "<table class='manage_retro'>"; > echo "<tr>"; > echo "<td>"; > echo "No results found"; > echo "</td>"; > echo "</tr>"; > } else { > echo WRITE THE DATA TO THE SCREEN > } >
OK first off your query shouldn't do a LIKE on the idStudent column because it's a numeric column So you need to try: $GETSTUDENT_query = "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 you want to be a little more advanced you can distinguish between a name and ID search... if( is_numeric( trim($_REQUEST['searchit']) ) ) { $GETSTUDENT_query = "Select * from STUDENTS WHERE idStudent = ".$_REQUEST['searchit'] ; } else { $GETSTUDENT_query = "Select * from STUDENTS WHERE lower(Trim(FName)) LIKE '%".strtolower(trim($_REQUEST['searchit']))."%' OR lower(trim(LName)) LIKE '%".strtolower(trim($_REQUEST['searchit']))."%" ; } // end if Can you post the html of your form... Does MySQL report an error? What version of MySQL and PHP are you using. If you are convinced that the data are correct you could do a check to see if there are any invisible non whitespace chars in the field values... SELECT Fname, length(fname), Lname, length(fname) from students ; Also a shot in the dark here but the table 'may' be corrupt so try an 'optimize table' http://dev.mysql.com/doc/mysql/en/OPTIMIZE_TABLE.html or Myisamchk http://dev.mysql.com/doc/mysql/en/myisamchk_syntax.html Cheers Dean -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]