My only concern would be the nonsensical markup.
Code:
SomeCategory<br />
<li>SubCategory</li>
*
Invalid HTML. That is gibberish/invalid markup since CDATA and BR again, cannot be siblings to LI. Since this is a category tree, it would actually make more sense for this to be a nested list. (though it's hard to say if you are omitting the actual output logic)
You also are using double quotes in a number of places where it makes no sense, like on echo -- why waste time taking longer when you don't have to. You also are using string additions in places where that doesn't make sense either. Single quotes on your echo's would let you have nicely formatted output that's easy to debug.
something like:
Code:
function categoriesLeft($table){
$parentResult = mysql_query("
SELECT * FROM $table
WHERE parent_id=0
");
echo '
<ul class="categoryTree">';
while ($parentRow=mysql_fetch_assoc($sql)) {
echo '
<li>
',$parentRow['categories_name'];
$childResult=mysql_query("
SELECT * FROM $table
WHERE parent_id=$result[categories_id]
");
if (mysql_num_rows($childResult)>0) {
echo '
<ul>';
while ($childRow=mysql_fetch_assoc($subs)) {
echo '
<li>',$row['categories_name'],(
$row['categories_id']==$_GET['id'] ? '*' : ''
),'</li>';
}
echo '
</ul>';
}
echo '
</li>';
}
echo '
</ul>';
}
Which would output something like:
Code:
<ul class="categoryTree">
<li>
ParentCategoryWithKids
<ul>
<li>ChildCategory</li>
<li>ChildCategoryMatchesGet*</li>
</ul>
</li>
<li>
ParentCategoryNoKids
</li>
</ul>
VALID HTML, it helps... a lot.
Bookmarks