in reply to Re: Can we use print <<HTML; twice in same file?
in thread [Solved]: Can we use print <<HTML; twice in same file?
When I see a repeating pattern I think 'can I loop this ?'
#!/usr/bin/perl use strict; use warnings; use DBI; use CGI; use CGI::Carp qw(fatalsToBrowser); # HTML my $q = new CGI; print $q->header; # start HTML printing in chunk print <<HTML; <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" +> <title>CommDesk Dashboard</title> <style type="text/css"> body { background-color: AliceBlue; } span.note1 {float:left} span.note2 {font-size:80%} table#t01, #t01 th, #t01 td { border: none; border-collapse: collapse; font-size:80%; } </style> </head> <body> <div style="float:left; width:50%"> <b>Call Volume Tab Configuration</b> <br/><span class="note2">Customize your personal view of the Call Volu +me Tab.</span> HTML
You need to put the database stuff back to replace the test values in @row, and probably the <form> tags but around the table not each input.my @stat = ( ['trunk_usage' ,'% Trunk Usage'], ['pre_ivr' ,'Pre-IVR Call Volume'], ['trunk_group' ,'Trunk Group Utilization'], ['average_speed','Average Speed of Answer'], ['outage_call' ,'Outage Call Volume'], ['ivr_call' ,'IVR Call Volume'], ['non_outage' ,'Non-Outage Call Volume'], ['post_ivr' ,'Post-IVR Call Volume'],); my @row = (1,0,1,1,1,0,1,0); #while (my @row = $sth->fetchrow_array) { print qq!<table id="t01"><tr>!; for my $i (0..$#stat){ my $chk = ($row[$i] == 1) ? 'checked' : ''; print qq!<td> <input type="checkbox" name="$stat[$i][0]" value="1" $chk /> $stat[$i][1] </td>!; if (($i % 2) && ($i < $#stat)){ print q!</tr><tr>!; } } print q!</tr></table>!; #} print q!</div></body></html>!;
|
|---|