been looking at too long...
| From: | Kelly Meeks | Date: | Thu, 11 Apr 2002 17:08:56 +0000 |
| Subject: | been looking at too long... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-92614@lists.php.net to get a copy of this message | ||
I'm under a deadline, and for whatever reason, can't figure out why this snippet of code
isn't working. I'm trying to build a site map function, (parent,child relationship based
on id).
It almost works, but I can't get the indent feature to work correctly. Any thoughts?
here's the code:
$connect=mysql_connect($bshostname,$bsusername,$bspassword);
$thedb=mysql_select_db($bsdatabase);
$thequery="select * from items where type='main'";
$theresults=mysql_query($thequery) or die(mysql_error());
function outputTree($parentid,$level)
{
$query="select id,name from items where whichpage='$parentid'";
$treeresults=mysql_query($query) or die (mysql_error());
while ($treebranch=mysql_fetch_assoc($treeresults))
{
for ($i = 0; $i < $level; $i++)
{
echo " ";
}
echo "$treebranch[name]<br>";
outputTree($treebranch["id"],$level++);
}
//end function
}
while ($output=mysql_fetch_assoc($theresults))
{
echo $output["name"]."<br>";
outputTree($output["id"],1);
}
?>