How does the PHP search page implement categorical retrieval

Source: Internet
Author: User
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);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.