Why is it whenever i do a dual search on the first value of drop down menu and the keyword(text field) search.. No results could be displayed..
I did a test the query on MySQL.. it returns results..
But if i were to search on other values of the drop down menu cept' for the first value together with the keyword search.. There were results..
Keyword Search
// Get the search variable from URL For Keyword Search
$Keyword = @$_GET['Keyword'] ;
//trim whitespace from the stored variable
$trimmedKeyword = trim($Keyword);
//separate key-phrases into keywords
$trimmed_arrayKeyword = explode(" ",$trimmedKeyword);
// Build SQL Query for each keyword entered
foreach ($trimmed_arrayKeyword as $trimmKeyword){
// EDIT HERE and specify your table and field names for the SQL query
$queryKeyword = "SELECT * FROM report WHERE DefectInfo LIKE \"%$trimmedKeyword%\" OR Rectifications like \"%$trimmedKeyword%\" OR Comments like \"%$trimmedKeyword%\" OR RelatedDoc like \"%$trimmedKeyword%\" ORDER BY DefectInfo DESC" ;
// Execute the query to get number of rows that contain search kewords
$numresultsKeyword =mysql_query ($queryKeyword);
$rowKeyword= mysql_fetch_array ($numresultsKeyword);
$row_num_links_mainKeyword =mysql_num_rows ($numresultsKeyword);
// next determine if 's' has been passed to script, if not use 0.
// 's' is a variable that gets set as we navigate the search result pages.
if (empty($_GET['s']))
{
$s=0;
}elseif (is_numeric($_GET['s'])){
$s = $_GET['s'];
}//end if
// now let's get results.
$queryKeyword .= " LIMIT $s,$limit" ;
$numresultsKeyword = mysql_query ($queryKeyword) or die ( "Could not execute query" );
$rowKeyword= mysql_fetch_array ($numresultsKeyword);
//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
$adid_array[] = $rowKeyword[ 'ReportID' ];
}while( $rowKeyword= mysql_fetch_array($numresultsKeyword));
} //end foreach
//delete duplicate record id's from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
$newarr = isSet($_POST['Search']) ? $_REQUEST['Search'] : '';
foreach ($tmparr as $v)
{
$newarr .= "'" . $v . "',"; //turn newarr into a comma separated string good for an in clause in a query
}
$newarr = substr($newarr,0,strlen($newarr)-1); //remove the trailing comma
Drop down search
// get the aircraft type
$queryAircraftType = "SELECT distinct AircraftType FROM report";
$resultAircraftType = mysql_query($queryAircraftType) or die ("couldn't execute query.");
$row_num_links_mainAircraftType =mysql_num_rows ($resultAircraftType);
<?php while($rowAircraftType = mysql_fetch_array($resultAircraftType)) {
if($rowAircraftType['AircraftType']==$_GET['AircraftType'])
{
echo "<option selected value='$rowAircraftType[AircraftType]'>$rowAircraftType[AircraftType]</option>"."<BR>";}
else
{
echo "<option value='$rowAircraftType[AircraftType]'>$rowAircraftType[AircraftType]</option>";}
}
?>
$queryAircraftDisplay = "SELECT * from report where 1";
if (!empty($_GET['AircraftType']))
{
$queryAircraftDisplay .= " and aircraftType='".$_GET['AircraftType']."' ";
}
if (!empty($_GET['Keyword']))
{
$queryAircraftDisplay .= " and reportID in ($newarr)";
}
$resultAircraftDisplay = mysql_query($queryAircraftDisplay) or die ("couldn't execute query ".mysql_error());
while ($row = mysql_fetch_array($resultAircraftDisplay))
{