CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
alternating color backgrounds in table


New User

Jan 12, 2010, 11:26 AM

Post #1 of 1 (1074 views)
alternating color backgrounds in table Can't Post


I try to do my own programming and then get stuck a lot of the time!!! A little help please so my head does not explode. :) Thanks.

The following snippet of code is from the template that is being called (you'll see where I use bgcolor="tmpl_var name=bg_list_color" in the script:

---------------------- snippet----------------

<table width="730" border="0" cellspacing="0" cellpadding="0" height="20">
<tr height="20">
<td height="20">
<div align="center">
<table border="0" cellpadding="0" cellspacing="5" width="726" align="left" bgcolor="#f5f5f5" height="24">
<tr bgcolor="tmpl_var name=bg_list_color" valign="top" height="18">
<td width="35" valign="top" height="18"><img src="../images/<tmpl_var name=money>" width="35" height="18" border="0" align="top"></td>
<td width="60" valign="top" height="18">
<div align="right">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<tmpl_var name=new_word>

------------------------ end of snippet ---------------

OK. So here is the .pl script which I can't figure out why it's not creating the alternate bg color?

------------- .pl script snippet -------------------

my @auditions = ();
my $db_query = "select audition_id, show_name, date, new_word, audition_city, color, money from auditions order by date";
my $now_year = $time[5] + 1900;
my $now_month = sprintf "%02d", ($time[4] + 1);
my $now_day = sprintf "%02d", $time[3];
my $now_date = "$now_year$now_month$now_day";
my $template = HTML::Template->new
(filename => "$CONFIG::forms_dir/list_auditions_color.tmpl");

$sth = $dbh->prepare($db_query);

my $bg_list_color="#cccccc";

while (my ($audition_id, $show_name, $date, $new_word, $audition_city, $color, $money) = $sth->fetchrow) {

if ($date >= $now_date) {
my $format_year = substr($date, 0, 4);
my $format_month = substr($date, 4, 2);
my $format_day = substr($date, 6, 2);
my $format_date = "$format_month - $format_day - $format_year";
my %row_data = ('audition_id' => $audition_id,
'show_name' => $show_name,
'date' => $format_date,
'new_word' => $new_word,
'audition_city' => $audition_city,
'color' => $color,

'bg_list_color' => $bg_list_color,
'money' => $money);

push @auditions, \%row_data;

if ($bg_list_color == "#cccccc")
$bg_list_color = "#ffffff";
$bg_list_color = "#cccccc";


# show list of all current auditions, as links to full info
$template->param('list_auditions' => \@auditions);

print "Content-Type: text/html\n\n", $template->output;



Thanks for any suggestions anyone has on this.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives