format tree traversal
Posted: Sat Apr 21, 2007 8:56 pm
feyd | Please use
So you can see that each new node will have a space before it, indenting each one accordingly. I don't want to do this in sql however. I want to be able to format this in php... any ideas how I would do that?
Thanks a lot!
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm using the tree traversal method for storing categories, what I can't figure out is how do I format it appropriatly in the php.. here is what I have for mysql
[syntax="sql"]
SELECT CONCAT( REPEAT( ' ', (COUNT(parent.name) - 1) ), node.name) AS name
FROM categories AS node,
categories AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name
ORDER BY node.lft;
Thanks a lot!
feyd | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]