Jump to content

Search form FULL TEXT SQL queries not working correctly


AdRock

Recommended Posts

I have search form where i can enter a keyword and i want to run a query that returns all results thjat have that keyword

 

The problem is, it is returning all the records instead of the filtered records

 

I am using MATCH to check all indexed fields with a variable to see if that variable appears in any of those fields

 

these are the variables that are got from the form.  i shall being using the $seats and $ dept later when i have this query working

$address = $_REQUEST['address'];
$seats = $_REQUEST['seats'];
$dept = $_REQUEST['dept'];

 

This is the queries

if(!empty($address) && !empty($seats) && !empty($dept)) {
    	$result = mysql_query("SELECT id,userid,seats_available,start_street,start_postcode,start_lat,start_long,
    end_street,end_postcode,end_lat,end_long,TIME_FORMAT(depart_time,'%H:%i') as depart, MATCH (start_street, start_postcode, end_street, end_postcode) AGAINST ($address) AS score FROM carshare ORDER BY score ASC LIMIT  
             	$offset,$entries_per_page");
    }
    else {
    	$result = mysql_query("SELECT id,userid,seats_available,start_street,start_postcode,start_lat,start_long,
    end_street,end_postcode,end_lat,end_long,TIME_FORMAT(depart_time,'%H:%i') as depart FROM carshare ORDER BY id LIMIT  
             	$offset,$entries_per_page");
    } 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.