I have this code
the part in bold I have added just to create some extra dummy records, this all works fine.
However when i display the results I get this..
and if you look @ the code where I add $_->{'Pos'} = $rnk; you will see I'm doing the simple increment and adding it to the template var.
If in the code I get it to print out $_->{'Pos'} it shows 1,2,3,4 etc.. as expected but the tmpl_loop is not showing each record.
Is this a bug in the template module? why am I getting this strange result when the code and all debuging shows the correct data.
many thanks, 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
Code:
# set time
my $time = time;
# Get Charts
my @rs = &getSQL("Charts","UserID,Title,Genre,Info,Plays,Votes,Rank,Best","1=1","Votes DESC");
[b]
for(my $x=1; $x<=39; $x++){
$rs[$x] = $rs[0];
}
[/b]
# Set Rank Counter
my $rnk = 0;
my $rcol = 0;
# Loop chart records
for(@rs) {
my $newt = "";
$rcol++;
# Get Status Info
my @stat = &getSQL("Status","TStamp","UserID='$_->{'UserID'}'");
# Work week to show if new
my $newtune1 = $stat[0]{'TStamp'} + 604800; # 7 days in seconds
my $newtune2 = $stat[0]{'TStamp'} + 2419200; # 28 days in seconds
if($newtune1 > $time){$newt = " style=\"color:#00EE00;\" ";}
elsif($newtune2 < $time){$newt = " style=\"color:#FFCC66;\" ";}
# Add 1 to rank counter
$rnk++;
# Build chart output
my $javaTitle = $_->{'Title'};
$javaTitle =~ s/'/\\'/g;
$_->{'JavaTitle'} = $javaTitle;
$_->{'Pos'} = $rnk;
$_->{'TuneCol'} = $newt;
$_->{'RowCol'} = $rcol;
if($rcol == 1){$_->{'RowCol'} = "#f5fafa";}
else{$_->{'RowCol'} = "#ffffff"; $rcol = 0;}
}
# Start template
my $template = HTML::Template->new( global_vars => 1,
type => 'filename',
source => DIR_TO_CGI . '/templates/top40.tp',
die_on_bad_params => 0) or die "Cannot open top40.tp Template file: $!";
# Add global variables to Template
$template->param( 'url_to_domain' => URL_TO_DOMAIN );
$template->param( 'url_to_cgi' => URL_TO_CGI );
$template->param( 'charts' => \@rs );
# Print Template
print "Content-type: text/html\n\n";
print $template->output;
exit();
However when i display the results I get this..
up to 40 records which is correct however the first number 40 is wrong, this should be 1,2,3,4 etc...40 / 1 dj-c.d.c. Only Love (Set Us Free) Dancecore 5 2 Play / Info / Vote
40 / 1 dj-c.d.c. Only Love (Set Us Free) Dancecore 5 2 Play / Info / Vote
40 / 1 dj-c.d.c. Only Love (Set Us Free) Dancecore 5 2 Play / Info / Vote
40 / 1 dj-c.d.c. Only Love (Set Us Free) Dancecore 5 2 Play / Info / Vote
40 / 1 dj-c.d.c. Only Love (Set Us Free) Dancecore 5 2 Play / Info / Vote
and if you look @ the code where I add $_->{'Pos'} = $rnk; you will see I'm doing the simple increment and adding it to the template var.
If in the code I get it to print out $_->{'Pos'} it shows 1,2,3,4 etc.. as expected but the tmpl_loop is not showing each record.
Is this a bug in the template module? why am I getting this strange result when the code and all debuging shows the correct data.
many thanks, 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.