Q: generate html - code libraries?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Malcolm Dew-Jones

    Q: generate html - code libraries?


    Is there a standard php library that one would normally use to generate
    bits of html?

    A typical task is to loop through some items and format them as the
    options for a <select> in a form.

    This sort of thing is so common I am assuming that at the code already
    exists to do all this sort of html generating, and all I need to do is
    "include" it and make a single function call in the right place.

    something like

    <?php include "html_tags. php" ?>
    <form><select >
    <?php echo show_options($m ylist,$choosen)
    ?></select></form>

    I assume I just haven't looked in the right place yet, or if I did then I
    didn't recognize the title for what it meant.

    Thanks.
  • Pedro Graca

    #2
    Re: Q: generate html - code libraries?

    Malcolm Dew-Jones wrote:[color=blue]
    > Is there a standard php library that one would normally use to generate
    > bits of html?
    >
    > A typical task is to loop through some items and format them as the
    > options for a <select> in a form.
    >
    > This sort of thing is so common I am assuming that at the code already
    > exists to do all this sort of html generating, and all I need to do is
    > "include" it and make a single function call in the right place.
    >
    > something like
    >
    > <?php include "html_tags. php" ?>
    > <form><select >
    > <?php echo show_options($m ylist,$choosen)
    > ?></select></form>
    >
    > I assume I just haven't looked in the right place yet, or if I did then I
    > didn't recognize the title for what it meant.
    >
    > Thanks.[/color]

    I use implode()

    <?php
    $data = array('one', 'two', 'three');

    echo '<select>';
    echo '<option>', implode('</option><option> ', $data), '</potion>';
    echo '</select>';
    ?>
    --
    USENET would be a better place if everybody read: | to email me: use |
    http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
    http://www.netmeister.org/news/learn2quote2.html | header, textonly |
    http://www.expita.com/nomime.html | no attachments. |

    Comment

    • Pedro Graca

      #3
      Re: Q: generate html - code libraries?

      Pedro Graca wrote:[color=blue]
      > echo '<option>', implode('</option><option> ', $data), '</potion>';[/color]
      ^^^^^^
      LOL -- Of course there is no potion in my HTML :-)

      --
      USENET would be a better place if everybody read: | to email me: use |
      http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
      http://www.netmeister.org/news/learn2quote2.html | header, textonly |
      http://www.expita.com/nomime.html | no attachments. |

      Comment

      • Garp

        #4
        Re: generate html - code libraries?


        "Malcolm Dew-Jones" <yf110@vtn1.vic toria.tc.ca> wrote in message
        news:40ce0e96@n ews.victoria.tc .ca...[color=blue]
        >
        > Is there a standard php library that one would normally use to generate
        > bits of html?
        >
        > A typical task is to loop through some items and format them as the
        > options for a <select> in a form.
        >
        > This sort of thing is so common I am assuming that at the code already
        > exists to do all this sort of html generating, and all I need to do is
        > "include" it and make a single function call in the right place.
        >
        > something like
        >
        > <?php include "html_tags. php" ?>
        > <form><select >
        > <?php echo show_options($m ylist,$choosen)
        > ?></select></form>
        >
        > I assume I just haven't looked in the right place yet, or if I did then I
        > didn't recognize the title for what it meant.
        >
        > Thanks.[/color]

        Tried Smarty template library yet? Template code looks like this:

        <select name="mylist">
        {foreach from=$mydata item=d}
        <option value="{$d.id}" >{$d.text}</option>
        {/foreach}
        </select>

        Garp


        Comment

        Working...