graham23s Posted June 13, 2007 Share Posted June 13, 2007 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 More sharing options...
Yesideez Posted June 13, 2007 Share Posted June 13, 2007 Try 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 Link to comment https://forums.phpfreaks.com/topic/55398-search-query/#findComment-273783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.