I'm trying to display some data stored into the database and i have this function but i don't know how it works :
public function resultToArray($result){
if(is_a($result, 'mysqli_result') && $result->num_rows > 0) {
$myArrayResult = array ();
while ($row = $result->fetch_assoc()) {
$myArrayResult[] = $row;
}
return ($myArrayResult);
}
else {
return ("Invalid Formart or Empty Result");
}
}
How can i use this in my fron-end? I've tried this method but it failed...
$listar = new classes_DbManager;
$result ="Select * FROM jobs_offers";
$query = $listar->resultToArray($result);
if(mysqli_affected_rows>0){
echo $row['username'];
}