Note that there are some explanatory texts on larger screens.

plurals
  1. PORecursive function with <ul><li>
    primarykey
    data
    text
    <p>currently I am displaying data in Text format with recursive function like..</p> <pre><code>Food Fruit Red Apple Yellow Banana Meat Beef Pork </code></pre> <p>and I am using following code to display this text</p> <pre><code>function display_children($parent, $level) { $result = mysql_query('SELECT * FROM category '. 'WHERE parant_id="'.$parent.'";'); while ($row = mysql_fetch_array($result)) { echo str_repeat(' ',$level).$row['name']."\n"; display_children($row['id'], $level+1); } } display_children(0,0); </code></pre> <p>But now I want to display the above text in <code>&lt;ul&gt;</code> <code>&lt;li&gt;</code> menu like</p> <pre><code>&lt;ul&gt; &lt;li&gt;Food &lt;ul&gt; &lt;li&gt;Fruit &lt;ul&gt; &lt;li&gt;Red &lt;ul&gt; &lt;li&gt;Apple&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Yellow &lt;ul&gt; &lt;li&gt;Banana&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Meat &lt;ul&gt; &lt;li&gt;Beef&lt;/li&gt; &lt;li&gt;Pork&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>All data is stored in table in following format</p> <pre><code>+----+-----------+--------+ | id | parant_id | name | +----+-----------+--------+ | 1 | 0 | Food | | 2 | 1 | Fruit | | 3 | 1 | Meat | | 4 | 2 | Red | | 5 | 2 | Yellow | | 6 | 4 | Apple | | 7 | 5 | Banana | | 8 | 3 | Beef | | 9 | 3 | Pork | +----+-----------+--------+ </code></pre> <p>please help me to display whole data in <code>&lt;ul&gt;</code> <code>&lt;li&gt;</code> format</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload