472,811 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Conditional statement to generate HTML?

Hi,

I'm an experienced programmer, but very new at perl, so please excuse
my newbishness :)

I am trying to modify an existing piece of perl code for an online
store that sells movies. Some of the videos in the inventory are now
available in DVD, so I want to add a DVD checkbox option for the
appropriate movies.

There is a boolean field in the database that is set to 1 if it is
available in DVD. Ideally, what I would like is an if-statement that
generates a piece of HTML if the boolean is true. However, it doesn't
seem that this can be done. Does anyone know how this could be
accomplished? I'm really at my wits end...

Thanks so much in advance!!
--Erica
Jul 19 '05 #1
3 5534
On Thu, 15 Jul 2004 21:52:36 -0700, Erica wrote:
Hi,

I'm an experienced programmer, but very new at perl, so please excuse
my newbishness :)

I am trying to modify an existing piece of perl code for an online
store that sells movies. Some of the videos in the inventory are now
available in DVD, so I want to add a DVD checkbox option for the
appropriate movies.

There is a boolean field in the database that is set to 1 if it is
available in DVD. Ideally, what I would like is an if-statement that
generates a piece of HTML if the boolean is true. However, it doesn't
seem that this can be done. Does anyone know how this could be
accomplished? I'm really at my wits end...

Thanks so much in advance!!
--Erica


Hi,

You need to investigate the code that fetchs the records from the database
and then you can add an C<if> conditional for your boolean value.

Example:
Suppose your DB looked like this:
id|^|movie's name|^|bool DVD

Now, you can have the following piece of code to generate your HTML:
open(FILE, 'your database file') or die($!);
flock(FILE, LOCK_SH);
while(<FILE>) {
chomp($_);
my @line = split(/\|\^\|/, $_);

# column #3 is your boolean value, so we test for it here
if ( $line[2] == 1 ) {
print "your html ...";
}
}
close(FILE);

The procedure is smiliar for a RDBMS like MySQL.

Good luck,

Jul 19 '05 #2
In article <34**************************@posting.google.com >, Erica wrote:
Hi,

I'm an experienced programmer, but very new at perl, so please excuse
my newbishness :)

available in DVD. Ideally, what I would like is an if-statement that
generates a piece of HTML if the boolean is true. However, it doesn't
seem that this can be done. Does anyone know how this could be
accomplished? I'm really at my wits end...


Of course it can be done:
if ($field == 1){ print "<html>...</html>";}
The exact implementation depends on your code, which you have not included.
--
{groeten|regards}, René van Leeuwen
___ _ __
/ _ \___ ___ ___// __/ /
/ , _/ -_) _ \/ -_) |/ / /__
/_/|_|\__/_//_/\__/|___/____/

Jul 19 '05 #3
Following Renees remarks, maybe the confusion is due to the fact
that Perl basically does not have explicit Boolean vars like
other programming languages do. The syntax for allmost all
vars is the same, Perl will determine the var type automatically.
On Thu, 15 Jul 2004 21:52:36 -0700, Erica wrote:
Hi,

I'm an experienced programmer, but very new at perl, so please excuse
my newbishness :)

I am trying to modify an existing piece of perl code for an online
store that sells movies. Some of the videos in the inventory are now
available in DVD, so I want to add a DVD checkbox option for the
appropriate movies.

There is a boolean field in the database that is set to 1 if it is
available in DVD. Ideally, what I would like is an if-statement that
generates a piece of HTML if the boolean is true. However, it doesn't
seem that this can be done. Does anyone know how this could be
accomplished? I'm really at my wits end...

Thanks so much in advance!!
--Erica


Jul 19 '05 #4

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

Similar topics

28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
7
by: Shaldaman | last post by:
I have an Access form called "Login". "Command10" is a button on the form and "Text5" is a text field on it. When a user enters a value in the Text5 text field and clicks the button Command10, I...
92
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if...
2
by: estafford | last post by:
I am having trouble writing a conditional block using ASP.NET and C#. I am trying to do something like this: 1. if page is PostBack - transfer to another page 2. if not postback - connect...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
5
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
11
by: Ciaran | last post by:
Is there a more efficient way to write this: if($var=1 || $var=4 || $var=27 || $var=28 || $var=30 || $var=37|| $var=38){echo "true";} Cheers, Ciarán
8
jschrader
by: jschrader | last post by:
I am trying to write a conditional Statement in ASP based on dates/times in a database entry. I'm basically a ASP/web designer and try my best to get into the fun coding, so not sure as to the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.