What I am trying to achieve is when you have a form drop down menu, it displays all the categories from the directory, with all the indentations. Something like when you submit your site to a directory.
Now I've got it almost working, but I can figure out how to indent it. The code below, I've used a spacer gif, but obviously that won't work!
I've had a go at this, as you can see, but that does do the indentations, unless I'm doing something wrong here.
Any help appreciated - thanks.
PHP Code:
CODE
function maketree($rootcatid,$level)
{
$sql="select catid,cat_name
from tbl_name
where parentid=$rootcatid
order by cat_name";
$result=mysql_query($sql);
while (list($DBcatid,$DBcatname)=mysql_fetch_row($result))
{
$width=($level+1)*24;
if ($width==48)
$display=" ";
if ($width==72)
$display=" ";
if ($DBcatid==1)
{
$display.="<option value=$DBcatid>";
}
else
{
$display.="<option value=$DBcatid>";
}
$display.="$DBcatname</option>";
echo $display;
maketree($DBcatid,$level+1);
}
}
?>
<table cellpadding="2" cellspacing="2" border="0" width="width="100%"">
<tr>
<td><select name="">
<? maketree(0,0);?>
</select></td>
</tr>
</table>
{
$sql="select catid,cat_name
from tbl_name
where parentid=$rootcatid
order by cat_name";
$result=mysql_query($sql);
while (list($DBcatid,$DBcatname)=mysql_fetch_row($result))
{
$width=($level+1)*24;
if ($width==48)
$display=" ";
if ($width==72)
$display=" ";
if ($DBcatid==1)
{
$display.="<option value=$DBcatid>";
}
else
{
$display.="<option value=$DBcatid>";
}
$display.="$DBcatname</option>";
echo $display;
maketree($DBcatid,$level+1);
}
}
?>
<table cellpadding="2" cellspacing="2" border="0" width="width="100%"">
<tr>
<td><select name="">
<? maketree(0,0);?>
</select></td>
</tr>
</table>


