search

Home  >  Q&A  >  body text

How to query with multiple conditions in PHP search box? ?

I am new to PHP. When writing the content of the search box, I found that I cannot query multiple conditions at the same time. Could anyone please give me some ideas on how to write it? I am grateful for 搜索框.png


# This is the pHP content written below:

& LT *) as total from tb_file where f_type=1"; //Find published content

                                $sql = mysqli_query($conn,$inquire);

                       $result = mysqli_fetch_assoc($sql ; #                                                                                            <td colspan="8" class="text-center">No query content yet, please search again</td>

                                                                                                                                                                                                                                                                             Pagination class

                                                                                                                                                                                                                 ! How to query multiple conditions at the same time

                                    $inquireCon = "select * from tb_file where f_qualitynum like '%$fileNum%' or f_filename like '%$fileName%' or f_department='$department' or f_classify='$qualityfile' order by f_date desc limit ".$page->limit()."";



                                    $sqlCon = mysqli_query($conn, $inquireCon);

                                    while($resultCon = mysqli_fetch_assoc($sqlCon)){

                                       ?>

                                       <tr>

                                           <td class="text-center" style="vertical-align: middle;"><input type="checkbox" name=""></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_qualitynum']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_filename']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_classify']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_grade']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_department']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><?php echo $resultCon['f_date']; ?></td>

                                           <td class="text-center" style="vertical-align: middle;"><input type="text" name="download" class="btn btn-default btn-xs" style="width: 50%;" value="下载" style="width: 80%;"></td>

                                        </tr>

                                       <?php

                                    }

                                 }

                              ?>


逆向行走逆向行走2046 days ago1927

reply all(3)I'll reply

  • WJ

    WJ2020-05-27 17:14:36

    if (strlen($SO['cate_id'])) {
        $filter[] = [
            'cate_label', 'like', "%," . trim($SO['cate_id']) . ",%"
        ];
    }
    if (strlen($SO['audit'])) {
        $filter[] = [
            'audit', '=', $SO['audit']
        ];
    }
    if ($SO['title']) {
        $filter[] = [
            'title', 'like', "%" . trim($SO['title']) . "%"
        ];
    }

    Let’s see if something like this works. This is how tp is written. For native, use splicing. I haven’t written native for a long time.

    reply
    0
  • 逆旅行人

    逆旅行人2019-06-22 22:56:37

    According to the data obtained, if it is not empty, the splicing conditions will be fine.

    reply
    0
  • 逆向行走

    逆向行走2019-06-21 09:21:52

    Upvote it, if you know anything, I hope you can help me. grateful

    reply
    0
  • Cancelreply