Answer the question
In order to leave comments, you need to log in
How to change the filtering code?
In general, there is such a code that filters the result, they say, for example, there is a result with the "Member" tag, then by the link "index.php
? =Member-Example-Stump-Navigation", etc., then the result with these tags is displayed.
The code itself:
$filter = NULL;
if(isset($_GET['filter'])){
$_GET['filter'] = sanitize($_GET['filter']);
if(preg_match('#[0-9]#',$_GET['filter'])) $filter = "AND `banner` = '" . $_GET['filter'] . "'";
elseif(strlen($_GET['filter']) == 2) $filter = "AND `country` = '" . $_GET['filter'] . "'";
else {
$category_id = mysql_result(mysql_query("SELECT `category_id` FROM `categories` WHERE `name` = '{$_GET['filter']}'"),0);
$filter = "AND `category_id` = '$category_id'";
}
}
Answer the question
In order to leave comments, you need to log in
1. You provide a piece of code, although the question concerns only one line
The rest of the code has nothing to do with the question as to whether it contains errors. For example, if filter=2 comes, then the first if will work and the check elseif(strlen($_GET['filter']) == 2)
will not even come to the point, although logically, this particular branch of the condition should be processed with a value of 2.
In addition, if you have already checked that $_GET['filter'] ) == 2, why write
Write immediately
Hmm, also moved away from the topic of the question :)
2. On the topic of the question.
Parse your filter
For example,
you will get an array of words
And then do with this array what you already need.
For example,
$names = explode("' , '", $arr);
mysql_query("SELECT `category_id` FROM `categories` WHERE `name` IN ('$names')")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question