doufeiqiong3515 2017-01-06 08:37
浏览 24

无法检索查询[重复]

I cant retrieve value from database. Below is my query

<?php
        $latestcover = queryTable("SELECT id, filename, title, thumbnail FROM borneo_ezone ORDER BY id DESC LIMIT 1");
        foreach ($latestcover as $key){
            echo '<p><a href="'.$key[1].'"><img src="'.$key[3].'" alt="Borneo Ezone '.$key[0].'" /></a></p>';
            echo '<p class="more">'.$key[0].'th issue of Borneo Ezone. <a href="'.$key[1].'">Read more &raquo;</a></p>';
        }

  ?>

Receive warning for PHP deprecated. How can I use mysqli to retrieve the query.

this my queryTable function

function queryTable($ask){

$query = mysqli_query($dbhandler,$ask); //query the db
$resArr = array(); //create the result array

while($row = mysqli_fetch_array($query)) { //loop the rows returned from db
    $resArr[] = $row; //add row to array
}
return $resArr;   

}

</div>
  • 写回答

1条回答 默认 最新

  • doufan9377 2017-01-06 08:44
    关注
    $latestcover = "SELECT id, filename, title, thumbnail FROM borneo_ezone ORDER BY id DESC LIMIT 1";
    
    if ($result = $mysqli->query($latestcover)) {
    
    
        while ($row = $result->fetch_row()) {
           echo '<p><a href="'.$row[1].'"><img src="'.$row[3].'" alt="Borneo Ezone '.$row[0].'" /></a></p>';
                echo '<p class="more">'.$row[0].'th issue of Borneo Ezone. <a href="'.$row[1].'">Read more &raquo;</a></p>';
        }
        $result->close();
    } 
    

    try this code

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大