473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Templates and HTML Select

For those of you using templates to keep your PHP and HTML code
separate.....

How do you handle a HTML Select statement when the initial option
selected needs to come from a database field?

--Bruce

Jul 17 '05 #1
2 2478
On Thu, 11 Mar 2004 13:21:54 GMT, Bruce <br*****@hotmail.com> wrote:
For those of you using templates to keep your PHP and HTML code
separate.....

How do you handle a HTML Select statement when the initial option
selected needs to come from a database field?


Well, depends on the templating system. I use Smarty, so I use:

<http://smarty.php.net/manual/en/language.function.html.options.php>

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2
"Bruce" <br*****@hotmail.com> wrote in message
news:bh********************************@4ax.com...
For those of you using templates to keep your PHP and HTML code
separate.....

How do you handle a HTML Select statement when the initial option
selected needs to come from a database field?


With TemplateTamer, I usually have template along these lines:

<select name="optionChooser">
<!--NAME:OPTION-->
<option value="{OPTIONVALUE}" {OPTIONSELECTED}>{OPTIONNAME}</option>
<!--END:OPTION-->
</select>

And then in logic file:

foreach ($options as $optValue => $optName) {
if ($optValue == $selectedValue)
$selected = 'SELECTED';
else
$selected= '';
$opt[] = array(
'OPTIONVALUE' => $optValue ,
'OPTIONNAME' => $optName,
'OPTIONSELECTED'=> $selected
);
}
You can see more on that example at:

http://www.templatetamer.org/index.p...ListboxExample

rush
--
http://www.templatetamer.com/
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5932
by: Sam | last post by:
I would like to store html templates in a database. By using perl I would like to retrive the template ask the user to fill the template and store the whole file is template + the user data in a...
1
2550
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a fixed header and a variable document part. The...
1
2795
by: Stefan Siegl | last post by:
Hello, I am trying to learn XSLT to use it in another project. I start reading the book "Java and XSLT" and tried the examples and they are went quite fine (how suprising *g*). Then I tried...
2
1651
by: Ruthless | last post by:
Hello. I've got a simple XML: <?xml version="1.0" encoding="iso-8859-2"?> <?xml-stylesheet type="text/xsl" href="4.xsl"?> <struct> <node level="1" no="1">
5
2516
by: Tom Alsberg | last post by:
Hi there... I'm recently trying to get a bit acquainted with XML Schemas and XSL. Now, I have a few questions about XSL stylesheets and templates: * Is there a way to "enter" a child element...
3
1632
by: bjam | last post by:
Help! The apply-templates function is not currently allowing me to select a specific template... eventhough I tried putting a select statement, it does not seem to work??? Can someone help show...
2
1615
by: jimbo_vr5 | last post by:
Hey I think i've figured out the idea behind apply-templates. But going through the tutorial on <http://www.w3schools.com/xsl/xsl_apply_templates.asp> theres simply just something that i dont...
3
1383
by: Christoph | last post by:
I'm still learning how to write stylesheets and the ones I've come up with for learning purposes are pretty simple and straightforward. I can get it to work, but probably not in the most ideal...
9
1624
by: patrik.nyman | last post by:
I have this templates to mark up hyphenation over line breaks: <xsl:template match="reg"> <xsl:apply-templates select="@orig"/> </xsl:template> <xsl:template match="reg/@orig">...
3
5905
by: Imaginativeone | last post by:
XML <nodeAA>AA</nodeAA> <nodeBB>BB</nodeBB> <nodeCC> <From>12/05</From> <To>11/06</To> <Months>12</Months> <Amount>10.00</Amount> ...
0
7229
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
7398
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...
1
7061
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
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.