I have been trying for over a day now to get FetchAll() method to help me display array from database. But all my efforts have failed. Instead of the print_r() returning an array, it gives me this array(). Kindly, help me out. The code in class page :
class Article {
public function fetch_all(){
global $conn;
$ass = $conn->prepare("SELECT * FROM articles");
$ass->execute();
return $ass->fetchAll();
}
}
while the code in display page is:
$article = new Article;
$articles = $article->fetch_all();
print_r($articles);
$query is not defined in your code, $ass->fetchAll(); is what you should have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With