Dynamic Html Using Looping Over Result Set

Discussion in 'PHP' started by zohaib82, Oct 24, 2012.

  1. #1
    Posted Yesterday, 12:52 PM
    Hi,

    I am creating menu using jquery-mega-drop-down-menu-plugin.

    I am stroing menu items in database and want to create html sturcture dynamically by looping over resultset

    I have attached working example.

    Following html need to create dynamically.

    
    [COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]Home[/COLOR][COLOR=#000088]</a></li>[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]About Us[/COLOR][COLOR=#000088]</a>[/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#000088]<ul>[/COLOR][COLOR=#000000]
              [/COLOR][COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]Menu Item 1[/COLOR][COLOR=#000088]</a></li>[/COLOR][COLOR=#000000]
              [/COLOR][COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]Menu Item 2[/COLOR][COLOR=#000088]</a></li>[/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#000088]</ul>[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000088]</li>[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]Services[/COLOR][COLOR=#000088]</a></li>[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000088]<li><a[/COLOR][COLOR=#660066]href[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"#"[/COLOR][COLOR=#000088]>[/COLOR][COLOR=#000000]Contact us[/COLOR][COLOR=#000088]</a></li>
    [/COLOR]
    Code (markup):



    Database Table for menu items as follow
    [COLOR=#000000]CREATE TABLE [/COLOR][COLOR=#008800]`headermenu`[/COLOR][COLOR=#666600]([/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#008800]`id`[/COLOR][COLOR=#000088]int[/COLOR][COLOR=#666600]([/COLOR][COLOR=#006666]11[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000] NOT NULL AUTO_INCREMENT[/COLOR][COLOR=#666600],[/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#008800]`text`[/COLOR][COLOR=#000000] varchar[/COLOR][COLOR=#666600]([/COLOR][COLOR=#006666]300[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000] DEFAULT NULL[/COLOR][COLOR=#666600],[/COLOR][COLOR=#000000]
      [/COLOR][COLOR=#008800]`parentid`[/COLOR][COLOR=#000088]int[/COLOR][COLOR=#666600]([/COLOR][COLOR=#006666]11[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000] DEFAULT NULL[/COLOR][COLOR=#666600],[/COLOR][COLOR=#000000]
      PRIMARY KEY [/COLOR][COLOR=#666600]([/COLOR][COLOR=#008800]`id`[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000] ENGINE[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#660066]InnoDB[/COLOR][COLOR=#000000] DEFAULT CHARSET[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#000000]latin1[/COLOR]
    Code (markup):
    Any solution?

    Thanks for time and efforts in advance.

    - Thanks
    Zohaib.Attached Files




     

    Attached Files:

    zohaib82, Oct 24, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    solution? for what? you didn't ask a real question!
     
    EricBruggema, Oct 25, 2012 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    I THINK OP's asking to do it in DHTML, when really this is more PHP or ASP's kind of job.

    But yeah, having trouble finding an actual question in there... I see the obvious mistake of pissing all over one's own website with jquery and some fat bloated rubbish "accessibility and graceful degradation, what's that" animated crap built with it... but not really seeing a question.
     
    deathshadow, Oct 30, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    As deathshadow said, a dynamic site (as opposed to dynamic HTML, which is a different thing) is done on the server, in ASP or (preferably) PHP (or Cold Fusion if you want to get jobs most people can't get). Since there's no way HTML can access the database (HTML is in the browser, the database is on the server), there's no way to make HTML use data from the database by itself, plain HTML or dynamic HTML.
     
    Rukbat, Nov 1, 2012 IP