Open
Description
Hello,
I am a student and would like to retrieve information from my database to display in a view. I have been trying for 2 days without success. Here is my code:
Models -> Menu:
<?php
namespace App\Models;
use PDO;
class Menu extends \Core\Model
{
public static function getAllMenu()
{
$db = static::getDB();
$stmt = $db->query('SELECT id, dish_name, dish_content, dish_option, dish_price, dish_img FROM recette');
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
Controllers -> Menu
<?php
namespace App\Controllers;
use \Core\View;
class Menu extends \Core\Controller
{
/**
* Show the index page
*
* @return void
*/
public $name;
public $content;
public $price;
public function indexAction($args)
{
$this->$args = [];
View::renderTemplate('Menu/index.phtml');
}
}
Views -> Menu (phtml)
<div class = "menu-wrapper" id="menu-wrapper">
<!-- Recettes -->
<div class="starters menu-restaurant">
<?php
echo 'Name:' . $args ['dish_name'];
?>
</div>
</div>
If someone to help me by telling me where the problem is coming from. I think it's from the Controllers. And how to display it in the view? Is this a return from a data table?
Thanks for your help
Metadata
Metadata
Assignees
Labels
No labels