Respected monks... I am trying to get this to print right, but seem to fail often. I am trying to print a 30 day calander (-15 days from today and +15 days from today) with todays date in bold which I have done, but cannot seem to get the 30 days to print using a table in CGI. Here is my code:
#!/usr/bin/perl #use strict; #use warnings; require "dbi-lib.pl"; use CGI qw/:standard *table start_ul/, (-unique_headers); use CGI::Carp qw(fatalsToBrowser); use DBI; my $cgi = new CGI; local $sth; #----------------------# # Function calls # #----------------------# print_header(); initialize_dbi(); #----------------# # Begin Main # #----------------# print $cgi->header(), $cgi->start_html ('Oreilly Lesson 11'), $cgi->h1 ({-style=>'Color:blue'},'SQL Class'); print "<u>",$cgi->strong('Date/Time CGI Table:'),"</u><p>"; print $cgi->caption('MySQL calendar table output, Lesson 11:'); print "<p>"; run_statement( "select date_format(curdate(), '%b %e, %Y');" ); my $today = $sth->fetchrow; run_statement("select dayofweek(curdate() );" ); my $dayofweek = $sth->fetchrow; #&run_statement( "select date_format(curdate()-2,'%W');" ); + #my $twodayago = $sth->fetchrow; #print "$twodayago <p>"; my %WeekDays = ( Sunday => 1, Monday => 2, Tuesday => 3, Wednesday => 4, Thursday => 5, Friday => 6, Saturday => 7 ); my ($day, $day1, $week,) = (0,0,0); my (@weeks, @weeks1, @weeks_anonymous,) = ((),(),()); ## Set up array with dates minus 15 days and plus 15 days from current + date ## foreach $day ('-15' .. '15') { run_statement( "select date_format(date_add(curdate(), interval '$ +day' day), '%b %e, %Y');" ); push (@weeks, $sth->fetchrow); } ## Match up dates with dayofweek #'s ## foreach $day1 ('-15' .. '15') { run_statement( "select dayofweek(date_add(curdate(), interval '$da +y1' day));" ); push (@weeks1, $sth->fetchrow); } ## Begin Table ## print table({border=>undef}); #print Tr ({-align=>'CENTER',-valign=>'TOP'}); @weeks_anonymous = ( [ $weeks[0], $weeks[1], $weeks[2], $weeks[3], + $weeks[4], $weeks[5], $weeks[6] ], [ $weeks[7], $weeks[8], $weeks[9], $weeks[10], + $weeks[11], $weeks[12], $weeks[13] ], [ $weeks[14], $weeks[15], $weeks[16], $weeks[17], + $weeks[18], $weeks[19], $weeks[20] ], [ $weeks[21], $weeks[22], $weeks[23], $weeks[24], + $weeks[25], $weeks[26], $weeks[27] ], [ $weeks[28], $weeks[29], $weeks[30], $weeks[31], + undef, undef, undef ], + ); foreach $element (@weeks_anonymous) { print Tr({-align=>'CENTER',-valign=>'TOP'}); for $date (@{$element}) { if (! defined $date) { print td (''); } elsif ($date eq $today) { print td(strong($date) ); } else { print td ($date); } } print $cgi->end_Tr; } print $cgi->end_html; # thank you !

In reply to cgi calander by mikejones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.