Skip to main content
October 22, 2009
Answered

How can I populate and unordered list from an sql table

  • October 22, 2009
  • 1 reply
  • 1371 views

Instead of hardcoding a static menu using an unordered list, I would like to populate it from a table

(just two fields, MenuID,MenuDesc) so that the menu can grow or shrink depending on what is in the table.

Tried googling this but cannot make head or tail of php server side recursive scripts, datareaders etc

Couild some kind person just spell it out for me:

<ul>

     <li>Form.MenuDesc<li>

     <li>Form.MenuDesc<li>

     <li>Form.MenuDesc<li>

      etc

<ul>

many thanks

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    Based on what you describe, both in DB schema and desired output, you don't need to worry about recursion because your data isn't hierarchical.

    Just query the DB and loop over the result set, outputting an <li/> for each record.

    --

    Adam

    1 reply

    Adam Cameron.Correct answer
    Inspiring
    October 22, 2009

    Based on what you describe, both in DB schema and desired output, you don't need to worry about recursion because your data isn't hierarchical.

    Just query the DB and loop over the result set, outputting an <li/> for each record.

    --

    Adam

    Inspiring
    October 22, 2009

    Regarding,

    Just query the DB and loop over the result set, outputting an <li/> for each record.

    Use the cfoutput tag with a query attribute to loop over the result set.

    October 22, 2009

    Hi Dan,

    Many thanks indeed for taking the trouble to respond.

    As you probably know, I'm a self taught amateur, so I need things spelled out.

    Presumably, you mean something like

    select MenuDesc from Menus

    ]]>

    Seems a bit too simple...