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

时间:2015-11-05 03:11:41

标签: php mysql mysqli

任何人都可以帮助我在哪里做错了吗?

以下是我的代码,我想获取类似于用户发布的搜索条目的文件名列表...

    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";}
}

我不明白为什么$result被发现为空,即使我提供了数据库中可用的条目。

0 个答案:

没有答案