MySQL interesse |
|
TotempaaltJ schreef: Elke variabele die je definieert in je class moet je halen uit $this, dus $this->_db->linkÂ
Waarom hoeft dat op lijn 12 niet dan?
Daarnaast, dit is de code nu, en ik houdt dezelfde foutmelding, ook met jou toevoeging....
<?php
require_once('database.php');
class Menu
{
private $_db;
function __construct()
{
$_db = new Database();
$result = mysqli_query($_db->link, 'SELECT id, name FROM menu');
echo '<ul id="nav">';
while($menu = mysqli_fetch_array($result))
{
echo '<li class="menu_knop"><a href="">' . $menu['name'] . '</a>';
$this->node($menu['id']);
echo '</li>';
}
echo '</ul>';
}
function node($nMenuID)
{
$result = mysqli_query($this->_db->link, 'SELECT name FROM menu_down WHERE child = ' . $nMenuID);
if(null != $result)
{
echo '<ul>';
while($menu = mysqli_fetch_array($result))
{
echo '<li><a href="">' . $menu['name'] . '</a></li>';
}
echo '</ul>';
}
}
}
new Menu();
?>
<?php require_once('database.php'); class Menu { private $_db; function __construct() { $_db = new Database(); $result = mysqli_query($_db->link, 'SELECT id, name FROM menu'); while($menu = mysqli_fetch_array($result)) { echo '<li class="menu_knop"><a href="">' . $menu['name'] . '</a>'; $this->node($menu['id']); } } function node($nMenuID) { $result = mysqli_query($this->_db->link, 'SELECT name FROM menu_down WHERE child = ' . $nMenuID); if(null != $result) { while($menu = mysqli_fetch_array($result)) { echo '<li><a href="">' . $menu['name'] . '</a></li>'; } } } } new Menu(); ?>
|