Jump to content

Search Query


graham23s

Recommended Posts

Hi Guys,

 

when i echo out my search query i get this:

 

SELECT * FROM `uploaded_files` WHERE `file_name` LIKE '%test%' OR `description` LIKE '%test%' AND `cat_id`='1' ORDER BY `date_added` ASC LIMIT 0, 25

 

cat_id = category id, if i do a search it still shows all categories rather than just the 1 i have selected

 

 

heres my coding:

 

        $results = $_GET['results'];
        $cat_id = $_GET['cat_id'];

	// Create our query, including our keywords...///////////////////////////////////
	$sql  = "SELECT * ";
	$sql .= "FROM `uploaded_files` ";
	$sql .= "WHERE `file_name` LIKE '%$keywords%' OR `description` LIKE '%$keywords%'";
	$sql .= " AND `cat_id`='$cat_id'";

	if($_GET['results'] == 'Ascending') {

	$sort_order = 'ASC';

	} else {

	$sort_order = 'DESC';

	}

	$sql .= " ORDER BY `date_added` $sort_order LIMIT $from, $max_results";

 

any help would be appreciated

 

cheers

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/55398-search-query/
Share on other sites

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.