<small id='EuA9L'></small><noframes id='EuA9L'>

<i id='EuA9L'><tr id='EuA9L'><dt id='EuA9L'><q id='EuA9L'><span id='EuA9L'><b id='EuA9L'><form id='EuA9L'><ins id='EuA9L'></ins><ul id='EuA9L'></ul><sub id='EuA9L'></sub></form><legend id='EuA9L'></legend><bdo id='EuA9L'><pre id='EuA9L'><center id='EuA9L'></center></pre></bdo></b><th id='EuA9L'></th></span></q></dt></tr></i><div id='EuA9L'><tfoot id='EuA9L'></tfoot><dl id='EuA9L'><fieldset id='EuA9L'></fieldset></dl></div>

  1. <tfoot id='EuA9L'></tfoot>
    <legend id='EuA9L'><style id='EuA9L'><dir id='EuA9L'><q id='EuA9L'></q></dir></style></legend>
      <bdo id='EuA9L'></bdo><ul id='EuA9L'></ul>

    1. mySqli 绑定参数 LIKE 与通配符

      时间:2023-09-25

      <small id='b27Yi'></small><noframes id='b27Yi'>

    2. <legend id='b27Yi'><style id='b27Yi'><dir id='b27Yi'><q id='b27Yi'></q></dir></style></legend>

        <tfoot id='b27Yi'></tfoot>
            <tbody id='b27Yi'></tbody>
          • <i id='b27Yi'><tr id='b27Yi'><dt id='b27Yi'><q id='b27Yi'><span id='b27Yi'><b id='b27Yi'><form id='b27Yi'><ins id='b27Yi'></ins><ul id='b27Yi'></ul><sub id='b27Yi'></sub></form><legend id='b27Yi'></legend><bdo id='b27Yi'><pre id='b27Yi'><center id='b27Yi'></center></pre></bdo></b><th id='b27Yi'></th></span></q></dt></tr></i><div id='b27Yi'><tfoot id='b27Yi'></tfoot><dl id='b27Yi'><fieldset id='b27Yi'></fieldset></dl></div>

                <bdo id='b27Yi'></bdo><ul id='b27Yi'></ul>
              • 本文介绍了mySqli 绑定参数 LIKE 与通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我在将带有通配符的 LIKE 绑定到 MySQLi 中准备好的语句时遇到问题.我尝试了以下两种方法,如下所示 &concat.(更新为@fancyPants 输入)

                I'm having issues binding the LIKE with Wildcard into my prepared statement in MySQLi. I tried both the following methods below as shown & concat.(updated with @fancyPants input)

                • 有没有办法在绑定发生后查看自己的 SQL 语句?

                • Is there a way so that I can view my own SQL statement after the binding happens?

                如何正确绑定以获得我想要的结果?

                How do I bind it properly to get the result I want ?

                它可以在没有 LIKE 语句的情况下工作.

                It works without the LIKE statement.

                我只能从使用某个搜索词中提取数据.我的代码有问题吗?

                I could only pull out data from using a certain search term. Is there anything wrong with my code?

                $str = $_POST["searchstr"];
                
                
                    if(isset($_POST['submit']))
                    {
                        $price=$_POST['price'];
                
                
                        if(!empty($_POST['chkbx']))
                        {
                            foreach($_POST['chkbx'] as $selected)
                            {
                
                
                                $sql= 'SELECT bookTitle, bookPrice FROM nbc_book WHERE catID LIKE "%'.$selected.'%" AND bookTitle LIKE "%'.$str.'%" AND bookPrice < ?';
                                $stmt=mysqli_prepare($con,$sql);
                                mysqli_stmt_bind_param($stmt,"i",$price);
                                mysqli_stmt_execute($stmt);
                                mysqli_stmt_bind_result($stmt, $bookTitle, $bookPrice); 
                                while ($stmt->fetch()) {
                                     echo $bookTitle.$bookPrice."<br>";
                                }
                            }
                        }
                    }
                

                推荐答案

                $searchStr =  'oracle';
                $sql= 'SELECT bookTitle, bookPrice FROM nbc_book WHERE catID LIKE ? AND bookTitle LIKE "%'.$searchStr.'%" AND bookPrice < ?';
                $stmt=mysqli_prepare($con,$sql);
                mysqli_stmt_bind_param($stmt,"ssi",$selected,$price);
                mysqli_stmt_execute($stmt);
                mysqli_stmt_bind_result($stmt, $bookTitle, $bookPrice); 
                while ($stmt->fetch()) {
                    echo $bookTitle;
                }
                

                这篇关于mySqli 绑定参数 LIKE 与通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 PHP 代码而不是 HTML 代码导入/包含 CSS 下一篇:检索所有行但第一条记录丢失

                相关文章

                最新文章

                • <bdo id='xxRxY'></bdo><ul id='xxRxY'></ul>

                  <legend id='xxRxY'><style id='xxRxY'><dir id='xxRxY'><q id='xxRxY'></q></dir></style></legend>
                1. <tfoot id='xxRxY'></tfoot>

                  <small id='xxRxY'></small><noframes id='xxRxY'>

                  <i id='xxRxY'><tr id='xxRxY'><dt id='xxRxY'><q id='xxRxY'><span id='xxRxY'><b id='xxRxY'><form id='xxRxY'><ins id='xxRxY'></ins><ul id='xxRxY'></ul><sub id='xxRxY'></sub></form><legend id='xxRxY'></legend><bdo id='xxRxY'><pre id='xxRxY'><center id='xxRxY'></center></pre></bdo></b><th id='xxRxY'></th></span></q></dt></tr></i><div id='xxRxY'><tfoot id='xxRxY'></tfoot><dl id='xxRxY'><fieldset id='xxRxY'></fieldset></dl></div>