Jump to content


Photo

Multilevelled SELECT (combobox)


  • Please log in to reply
No replies to this topic

#1 pl0x

pl0x
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 13 April 2006 - 02:24 PM

I have this code, but result is empty ...
Help me =)

<?php
$a_tree=array();
$r=mysql_query("select c.id,c1.id as qqq, c.name from catalog c
left join catalog c1 on c.parentcatalog=c1.id order by c.name");

for($i=0;$i<mysql_num_rows($r);$i++)
{
$f=mysql_fetch_assoc($r);
if(empty($a_tree[$f['id']]))
$a_tree[$f['id']]=array();
$a_tree[$f['id']][]=$f;
}

function tree_print($a_tree,$k_parent=0)
{
if(empty($a_tree[$k_parent])) return;

echo "<ul>";
for($i=0; $i < count($a_tree[$k_parent]);$i++)
{
echo "<li>".$a_tree[$k_parent][$i]['name'];
tree_print($a_tree,$a_tree[$k_parent][$i]['id']);
echo "</li>";
}
echo "</ul>";
}
tree_print($a_tree);
?>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users