我无法从数据库中检索值。以下是我的查询
<?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 »</a></p>';
}
?>
收到PHP弃用的警告。我如何使用mysqli来检索查询。
这是我的queryTable函数
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;
}
答案 0 :(得分:0)
$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 »</a></p>';
}
$result->close();
}
试试这段代码