Undefined Offset 0 , how can i set this array
问题 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 '