Código PHP:
function menuList($data, $parent = 0 )
{
static $i = 1;
$tab = str_repeat(" ",$i);
if($data[$parent])
{
$html = "$tab<ol class='sortable' id='sortable'>";
$i++;
foreach($data[$parent] as $v)
{
$child = menuList($data, $v->id);
$html .= "$tab<li><div>";
$html .= '<a href="'.$v->url.'">'.$v->title.'</a>';
if($child)
{
$i--;
$html .= $child;
$html .= "$tab";
}la siguiente
$html .= '</div></li>';
}
$html .= "$tab</ol>";
return $html;
}
else
{
return false;
}
}
$query = mysql_query("SELECT * FROM menus ORDER BY sort");
while($r=mysql_fetch_object($query))
{
$data[$r->parent_id][] = $r;
}
$menu = menuList($data);
echo $menu;
?>
Undefined index: 8 in linea
Código PHP:
"if($data[$parent]"