开发者

creating a dynamic menu using php and mysql

开发者 https://www.devze.com 2023-01-09 09:17 出处:网络
this is what I need to genarate <ul id=\"0\"> <li >1</li> <ul id=\"1\"> <li > 11</li>

this is what I need to genarate

<ul id="0">
 <li >1</li>
   <ul id="1">
      <li > 11</li>
      <li > 12</li>
   </ul&g开发者_高级运维t;
 <li > 2</li>
   <ul id="2">
      <li > 21</li>
      <li > 22</li>
   </ul>
 <li > 3</li>
<ul>

this is my "menu_item" table

id            int(11)
title         varchar(75)
link          varchar(100)
parent_id     int(11)
position      int(11)

//parent_id of 1st layer(menu categories) is 0

I got the table rowset order by parent_id and position by

SELECT 'id','title','link','parent' FROM 'menu_item'
ORDER BY 'parent_id' AND 'position';

I don't know how to generate the html code for the menu using this data. thank you


ref 1
ref 2

0

精彩评论

暂无评论...
验证码 换一张
取 消