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 3 5556
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,
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
___ _ __
/ _ \___ ___ ___// __/ /
/ , _/ -_) _ \/ -_) |/ / /__
/_/|_|\__/_//_/\__/|___/____/
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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;
|
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
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
| |