473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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($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
3 1684
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Fred | last post by:
Hi, I'm sure there are a bunch of them, but googling just returned full-fledged CMS that require a DBMS and generate dynamic pages. I'd just like a script that would 1. look in a directory...
16
by: Tran Tuan Anh | last post by:
Dear all: I need your advice on this matter. I am working on a program which takes some pieces of System-C code in and generate some other System-C code. (System-C code is just C++ with some...
1
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
4
by: Shole Chan | last post by:
Do i need any plug-in ?? Suppose i am using code 39 format .... thanks for helping ~ I am just a chinese, sorry for my poor english >.<
3
by: Niklas Norrthon | last post by:
I just want to share a technique I discovered when playing around with templates. It is a simple idea, so I doubt I am first, perhaps it's even used in the standard library implementations, and...
78
by: Robert Baer | last post by:
The homepage i have had up and seemingly working is: http://oil4lessllc.com/ However, the validator has so many complaints, and being so incompetent, i have no clue as to how to fix it all. Would...
9
by: MyInfoStation | last post by:
Hi all, I am a newbie to Python and would like to genereate some numbers according to geometric distribution. However, the Python Random package seems do not have implemented functionality. I am...
6
by: ash | last post by:
i have a web page using frameset split into few pages. And I want to generate one page of HTML code and send it through email. My question is have to generate a HTML page using asp? Thx very much.
111
by: Nate | last post by:
Hello, I am looking for a method to automatically declare variables in C. I'm not sure if there is a good way to do this, but I had something like this in mind... int i; for(i = 1; i < 4;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.