By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

Q: generate html - code libraries?

P: n/a

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($mylist,$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.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Malcolm Dew-Jones wrote:
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($mylist,$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.


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. |
Jul 17 '05 #2

P: n/a
Pedro Graca wrote:
echo '<option>', implode('</option><option>', $data), '</potion>';

^^^^^^
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. |
Jul 17 '05 #3

P: n/a

"Malcolm Dew-Jones" <yf***@vtn1.victoria.tc.ca> wrote in message
news:40******@news.victoria.tc.ca...

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($mylist,$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.


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
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.