Hi everyone,
I’ve built an upload system, so when the administrator uploads a PDF file it gets listed on a page in the backoffice.
However, when I upload the PDF file I get weird results.
Page where I’m listing PDF’s and calling function:
...
$pdfs = $queries->getList();
if(is_array($pdfs)){
foreach($pdfs as $pdf){
echo "<span class=\\"alertgray\\"><strong>Title:</strong></span><span>".$pdf['title']."</span>";
}
}
Queries.class.php file - getList function:
public function getList() {
$populate = new Populate();
$query = "SELECT *
FROM pdfs
ORDER by date DESC LIMIT 5";
return $populate->pullListContent($query);
}
Populate.class.php file - pullListContent function:
function pullListContent($query){
$result = $this->db->query($query);
if($result)
return $result->fetch_assoc();
else
return false;
}
Output:
Title:3
Title:F
Title:0
Title:2
Title:M
Title:/
I only have one PDF on my database.
Everything worked great with:
return $result->fetch_all(MYSQLI_ASSOC);
But I can’t use that way because mysqli_result::fetch_all() function requires the MySQL native drivers and I can’t have it on my online server.
Any suggestions?
Thank you in advance!
Best regards.