Hello i have an Undefined Offset 0 . inside this code.
$q = mysql_query("SELECT * FROM category");
if (false === $q) {
echo mysql_error();
}
while ($r = mysql_fetch_row($q)) {
$names[$r[0]] = $r[2];
$children[$r[0]][] = $r[1];
}
function render_select($root=0, $level=-1) {
global $names, $children;
if ($root != 0)
echo '<option>' . strrep(' ', $level) . $names[$root] . '</option>';
foreach ($children[$root] as $child)
render_select($child, $level+1);
}
echo '<select>';
render_select();
echo '</select>';
The exact line where the error is :
foreach ($children[$root] as $child)
render_select($child, $level+1);
This is for a selectbox with a tree format, i found this code in this question
More efficient hierarchy system