php/mysql special tree
I 开发者_高级运维was messing arround with code and i can't figure out to do this:
I have a Table in the database like this:
CREATE TABLE IF NOT EXISTS `nodetree` (
`node` int(11) NOT NULL,
`prevnode` int(11) NOT NULL,
`nextnode` int(11) NOT NULL,
`nodename` varchar(30) NOT NULL,
`nodelink` varchar(255) NOT NULL,
PRIMARY KEY (`node`,`prevnode`, `nextnode`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
What i want to do is to get php build that graph automatically with tables. Each node is a clickable link to node description.
Thanks in advance.
By definition a node in a tree can only have one parent. But that isn't the case in your example. What you really have here is a directed graph, not a tree. You might want to have a look at this link for a good example of how to represent and query a graph in SQL.
精彩评论