Ask to use TP do similar to Taobao kind of multilevel screening with if statement control found one or two fields fortunately control, pass three fields above is not good control, filtered out the data is wrong. Is there any good way to do it?

Source: Internet
Author: User
      Multilevel screening $name =$_get[pid];                     $brand =$_get[theme];                     $carage =$_get[price];                                        Echo $carage;                     if ($name = "Pump Car" and $brand = "31") {$handmebuyinfo =m ("Handmebuyinfo");                     $map [' name ']= $name;                     $map [' Brand ']= $brand;                     $map [' Carage ']= $carage;                     $row = $handmebuyinfo->where ($map)->select ();                     Dump ($row);                     if ($name = = "or $brand = =" or $carage = = ") {                     $handmebuyinfo =m ("Handmebuyinfo");                     $map [' name ']= $name;                     $map [' Brand ']= $brand;                     $map [' Carage ']= $carage;                     $map [' _logic '] = ' OR ';                     $row = $handmebuyinfo->where ($map)->select ();    Dump ($row);                 } 


Reply to discussion (solution)

Your screening is a relationship with (and)
If there is more than one choice within the group, then the group is or (or) the relationship, such as the simultaneous selection of the pump Truck and mixer truck
But you don't have that demand right now.

You use ORM, so the assembly work is done by ORM.
You just have to ensure that you do not pass NULL parameters to it $_get = Array_diff ($_get, Array ("));
It is best to pass in the same name as the corresponding field, so that you do not need to program the corresponding data.
Like TP with a name mapping function, you can use

Your screening is a relationship with (and)
If there is more than one choice within the group, then the group is or (or) the relationship, such as the simultaneous selection of the pump Truck and mixer truck
But you don't have that demand right now.

You use ORM, so the assembly work is done by ORM.
You just have to ensure that you do not pass NULL parameters to it $_get = Array_diff ($_get, Array ("));
It is best to pass in the same name as the corresponding field, so that you do not need to program the corresponding data.
Like TP with a name mapping function, you can use

Compare the difference set in the array a little bit clear, can you give me an example to see?

$a = Array (  ' a ' = = 1, ' b ' = = ', '  c ' = = 0,);p rint_r (Array_diff ($a, Array (")));p Rint_r (Array_diff ( $a, Array (", 0)));
Array (    [A] = 1    [c] + 0) Array (    [A] = 1)
This will not require if ($name = = ") to judge the

$a = Array (  ' a ' = = 1, ' b ' = = ', '  c ' = = 0,);p rint_r (Array_diff ($a, Array (")));p Rint_r (Array_diff ( $a, Array (", 0)));
Array (    [A] = 1    [c] + 0) Array (    [A] = 1)
This will not require if ($name = = ") to judge the

I got it, it started with
$map [' name ']= ' Null ';
$map [' Brand ']= $map [BRAND];
$map [' Carage ']= $map [carage];
$row = $handmebuyinfo->where ($map)->select ();
Dump ($row), quick query query does not have the data, the original is here the face value is not allowed to empty, so remove these direct assignment query is no problem.
  • 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.