search

Home  >  Q&A  >  body text

Novice advice: how to write php multi-condition query search MYsql

According to such query conditions, how to search for the user name and password in the database?

2.png1.png

苏小刚苏小刚2320 days ago1418

reply all(7)I'll reply

  • **推广网

    **推广网2018-10-10 11:35:52

    Directly add multiple and   conditions after where. If the value is not selected, it will be empty.

    reply
    0
  • Summer

    Summer2018-08-14 11:32:31

    Cannot upload pictures. . .

    reply
    0
  • Summer

    Summer2018-08-14 09:57:48

    good

    reply
    0
  • Summer

    Summer2018-08-14 09:56:30

    Add the last one yourself

    reply
    0
  • Summer

    Summer2018-08-14 09:53:42

    Add the last one yourself

    reply
    0
  • ll

    ll2018-08-13 17:21:16

    if($chengbenjia!=0){

    switch ($chengbenjia) {

    case 1:

    $sql = $sql."and cost_price>=0 and cost_price<=99 ";

    break;

    case 2:

    $sql = $sql."and cost_price>=100 and cost_price<200 ";

    break;

    case 3:

    $sql = $sql."and cost_price>=200 and cost_price<=299 ";

    break;

    case 4:

    $sql = $sql."and cost_price>=300 ";

    break;

    case 5:

    $sql = $sql."and cost_price =0 ";

    break;

    }

    }

    if($shoujia!=0){

    switch ($shoujia) {

    case 1:

    $sql = $sql."and sellprice>=0 and sellprice<=99 ";

    break;

    case 2:

    $sql = $sql."and sellprice>=100 and sellprice<200 ";

    break;

    case 3:

    $sql = $sql."and sellprice>=200 and sellprice<=299 ";

    break;

    case 4:

    $sql = $sql."and sellprice>=300 ";

    break;

    }

    }


    我也是刚学php没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚

    reply
    0
  • 苏小刚

    Do I need to splice sql statements based on conditions and passed values? How to write sql statements? I am also a novice and I just learned it for a week.

    苏小刚 · 2018-08-13 19:18:06
  • Cancelreply