I can't get my data from database , I keep getting the same error
Notice: Undefined variable: articles in :\xampp\htdocs\SalesManagementProject\Views\articles.php on line 25
Warning: Invalid argument supplied for foreach() in :\xampp\htdocs\SalesManagementProject\Views\articles.php on line 25
my loop
<?php
foreach($articles as $art)
{
echo '<tr>
<td>'.$art['Id'].'</td>
<td>'.$art['ref'].'</td>
<td>'.$art['desig'].'</td>
</tr>';
}
?>
Model
<?php
class ArticlesModel
{
public function getArticles()
{
$pdo=new PDO_connect();
$q= $pdo->PDO()->query('SELECT * FROM articles');
return $q->fetchAll();
}
}
?>
Controller
<?php
class ArticlesControllers
{
public function loadArticles()
{
include (dirname(__FILE__).'/../Models/ArticlesModel.php');
$art_table = new ArticlesModel();
$articles = $art_table->getArticles();
include(dirname(__FILE__).'/../Views/articles.php');
}
}
?>
index
<?php
session_start();
include ('PDO_connect.php');
$p='home';
if (isset($_GET['p']))
{
$p=$_GET['p'];
}
include('Controllers/ArticlesControllers.php');
$arts=new ArticlesControllers();
$arts->loadArticles();
?>
So what i must do?