How does the PHP search page implement categorical retrieval?
This post was last edited by u010572351 on 2013-06-22 10:09:22
Is this, a mall or movie station, I now need to conduct various searches, such as
Separate, search by type, will
A separate, chronological search will
Separate, search by origin, will
However, if I choose the type, then I choose the origin, then choose the age, or the three of the various combinations of operations, very complex, do not know how to deal with,
Please expert guidance, mainly how to retain the previous user click on the filter parameters?
Then is the origin, the age, the type of link is really not good to write, because can not write death into a separate,
I am now the age of the parameter, the type is only the parameters of their own type, the origin is the origin of the parameters, such as:
Mainland
Action
2011
There is only one condition, can not coexist, and can not achieve multi-conditional filtering.
How do you get this?
Share to:
------Solution--------------------
$area =$_get[' area '];//get value you need to handle it yourself.
$type =$_get[' type '];
$year =$_get[' year ';
$sql = "SELECT * FROM shop where 1";
$sql. =isset ($area)? "and Area= ' $area '": ";
$sql. =isset ($type)? "and Type= ' $type '": ";
$sql. =isset ($year)? "and Area= ' $year '": ";
$result =mysql_query ($sql);
While ...
I hope my answer will be of help to you.
------Solution--------------------
Look, you do it.
echo Join ('-', $_get), '
';
$dict = Array (
' Area ' = = Array (' Inland ', ' RTHK '),
' type ' = = Array (' Action ', ' Love '),
' Year ' = = Array (' 2001 ', ' 2013 '),
);
foreach ($dict as $key = = $item) {
$param = $_get;
foreach ($item as $v) {
$param [$key] = $v;
$t = Http_build_query ($param);
echo "$v";
}
Echo '
';
}
------Solution--------------------
You can also use session processing
Session_Start ();
if (! isset ($_session[' search '))
$_session[' Search ' = Array ();
$_session[' Search ' = array_merge ($_session[' search '), $_get);
echo Join ('-', $_session[' search ']), '
';
?>
Mainland
Action
2011
------Solution--------------------
You're using it. Tag jump, no JS required
echo Join ('-', $_get), '
';
is to allow you to visually observe the changes in the selection.
------Solution--------------------
Has your program file been saved as search1.php?
------Solution--------------------
Give a more relaxed condition (whatever file name you want to save, and then prefix PHP).
Session_Start ();
------Solution--------------------
! $_get)
$_session[' Search ' = Array ();
$_session[' Search ' = array_merge ($_session[' search '), $_get);