Re: Re: HTML_TreeMenu-1.1.3 (stable) Released question
| From: | Richard Heyes | Date: | Thu, 20 Feb 2003 17:24:32 +0000 |
| Subject: | Re: Re: HTML_TreeMenu-1.1.3 (stable) Released question | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13511@lists.php.net to get a copy of this message | ||
> I used the code below and it seems the class half-worked, however I'm
unclear
> about the 3rd element of the assoc. array argument to
createFromStructure($params) .
This is the same options array as what the HTML_TreeNode takes as its first
argument.
> <?php
> include './Tree.php';
>
> $tree = &Tree::createFromMySQL(array('host' => 'localhost',
> 'user' => 'root',
> 'pass' => '',
> 'database' => 'parcelnumber',
> 'query' => 'SELECT id, parent,
name
> FROM cattest ORDER BY parent, id'));
You should note this from the Tree class inline docs:
query The query to perform. This must return
at least two columns, "id", and "parent_id".
other columns will be used as tag data. An example:
SELECT id, parent_id FROM structure ORDER BY parent_id, id
The query MUST be ordered by parent_id, then id.
So update your query to:
SELECT id, parent AS parent_id, name AS text FROM cattest ORDER BY
parent_id, id
(Aliasing name as text will mean that your name field will be used as the
text for the node in the treemenu).
--
Richard Heyes