-3

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;   

}

Fahmy
  • 1
  • 2

1 Answers1

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 &raquo;</a></p>';
    }
    $result->close();
} 

try this code