473,404 Members | 2,174 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,404 software developers and data experts.

I'm looking for a simple template with "optional" fields

I'm looking for a simple template with the following property: I want
to have in the resulting page something like this (say):

<div>
This is some text that never changes:
[[[$this is some variable that can be set from the calling PHP
code]]]
This is some more text that never changes
</div>

The crux is that if the calling code never initializes the variable,
then I want the entire <divnot to be displayed.

The use-case that I see is this: I have a program that mostly needs to
display long(ish) lists to the clients, but the lists can be
customized. Sometime I want to display the first five columns for each
row, sometime the last four columns, other times only the odd-numbered
columns, etc.

What I want, is to have only the following in my PHP code:

$qry = "SELECT [[[whatever fields I'm interested in]]] FROM mytable
WHERE...";
$res = db_query($qry);
while ($row = db_fetch_assoc($res)) {
$template->add_params($row);
$template->print();
}

In the template I will have something like this:

{<td>[[[$col1-name]]]</td>}
{<td>[[[$col2-name]]]</td>}
....

and only the <td>'s whose column is actually included in $row will be
displayed.

It seems quite trivial to write such a template (I really don't need
much logic there at all), probably a week worth of work. But it will
be even better if I can just use something out there instead.

Thanks,

-- Shai
Jan 18 '08 #1
0 1109

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

Similar topics

3
by: Paramesh | last post by:
Hello friends, My friend asked me this question: This question regards proprietary software (of which I am one of the developers), so I cannot post actual code for this question. I will try...
5
by: (Pete Cresswell) | last post by:
I've dabbled in "Optional" over the last few days and think I'm coming down against using it. Seems to me like it makes the code harder to read and more complicated. Instead of using Optional,...
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
2
by: Steve | last post by:
Kind of a strange question... I have a VB.NET 2.0 solution containing a main project (my EXE) and a number of other projects (class DLLs) that are "plug-ins" to the main app. These plugins get...
8
by: Zohar | last post by:
Hi, I've created a web service which uses a structure that I've defined. This structure contains a string and a DateTime. When the WSDL is created the string field is assigned a minoccurs of 0,...
1
by: Sinex | last post by:
Hi, I have a webmethod. It takes an int parameter. I want this to get serialized as an XMLAttribute...so I used the XMLAttributeAttribute decoration and it works fine. Now, I want to specify...
6
by: Queez | last post by:
I've had a good look around and no-one seems to have mentioned this, which leads me to believe that I may be missing something simple. Basically, is there a way I can do the following, and if so,...
3
by: Rincevent | last post by:
Hi, I'm trying to process a large number of files, each with a very small size (about 500 chars maximum). I need to retrieve multiple information from each file, and some of these are optional. So...
6
by: .rhavin grobert | last post by:
hello;-) i frequently need the following construction: ReturnParam § Function() § { /...do something.../ someType var § = something; /...do something.../ return something;
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
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...

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.