douyonglang4845 2015-11-05 03:11
浏览 10

如何在MySQLi连接中使用L​​IKE与select

Can anyone help where am I doing wrong?

The following is my code where I want to get the list of file names resembling the search entry posted by user...

    if (isset($_GET["search"]))
{
    $s_txt=$_GET["search"];

    if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; }; 
$start_from = ($page-1) * 27; 
$sql = "SELECT * FROM playlist WHERE name LIKE '%$s_txt%', 27"; 
$rs_result = mysqli_query ($mysqli, $sql); 
?> 
<ul class="test">

<?php 
if ($rs_result!='')
{
while ($row1 = mysqli_fetch_array($rs_result)) {

                                $pl_thumb = "admin/uploads/album/".$row1['name']."/".$row1['thumb'];
                                $pl_id = $row1['id']; 
                                $pl_name = $row1['name'];
                                $pl_usid = $row1['user_id'];
                                $pl_desc = $row1['description'];
?> 

            <li>
                                <div style="background-color: #000000; height: 160; width: 100%;" >
                                <p align="center">
                                <a href='index.php?list=album&albumid=<?php echo $pl_id; ?>'>
                                <img src="<?php echo $pl_thumb; ?>" height="160"     style="background-color: #000000"  /></a>
                                </p></div>
                                <div style="width: 100%; height: 80px; overflow-y:scroll; background-color: #FFFFFF; Position: Relative;  top:-15px; left: 0;">
                                  <p align="center"><span>
                                  <a href='index.php?list=album&albumid=<?php     echo $pl_id; ?>'>
                                  <font color="#6699FF" size="3"><b><?php echo     $pl_name; ?>,</font></span></b></a><span><font color="#000000"><br>
                                  </font>

                                  <font color="#000000" size="2pt"><?php echo        $pl_desc; ?></font>
                                </a>
                                  </span>
                                </div>
                            </li>             


<?php 
}; 
?> 
</ul>
</section>
<ul class="test">
<?php
$sql = "SELECT COUNT(id) FROM playlist"; 
$rs_result = mysqli_query($mysqli, $sql); 
$row = mysqli_fetch_row($rs_result); 
$total_records = $row[0];
$total_pages = ceil($total_records / 27);

for ($i=1; $i<=$total_pages; $i++) { 
    echo "<div style='Position: Relative;'><a href='index.php?list=album&page=".$i."'>".$i."</a></div>"; 
}
}
else{echo"No matching '$s_txt' result found";}
}

I cannot see why $result is found empty, even if I give an entry that is available in the database.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用