Jump to content

Archived

This topic is now archived and is closed to further replies.

pl0x

Multilevelled SELECT (combobox)

Recommended Posts

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);
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.