Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Need help to use a mySQL query to create a calendar from PERL (http://www.go4expert.com/forums/help-mysql-query-create-calendar-perl-t25026/)

aparikh_76 19Feb2011 00:23

Need help to use a mySQL query to create a calendar from PERL
 
i have the following assignment and have no idea where to start.

Create a PERL script that uses DBI that will list 30 consecutive dates with today's date as the 15th date in a table. The 15th date should be in bold. Enter the dates in a specific format. The month should be in English and the year should have four digits. The table should use the HTML table tag with Sunday as the first column. The date functions of PERL should Not be used! Everything should be done in the mySQL query. Note: for this objective, there is no need to create any tables in mySQL! You are simply using the functions of mysql in your DBI mysql query.

For example, if today's date was 12-25-1999, then the following would be listed:
Code:

Sunday        Monday        Tuesday        Wednesday        Thursday        Friday        Saturday
Oct 11, 2008
Oct 12, 2008        Oct 13, 2008        Oct 14, 2008        Oct 15, 2008        Oct 16, 2008        Oct 17, 2008        Oct 18, 2008
Oct 19, 2008        Oct 20, 2008        Oct 21, 2008        Oct 22, 2008        Oct 23, 2008        Oct 24, 2008        Oct 25, 2008
Oct 26, 2008        Oct 27, 2008        Oct 28, 2008        Oct 29, 2008        Oct 30, 2008        Oct 31, 2008        Nov 1, 2008
Nov 2, 2008        Nov 3, 2008        Nov 4, 2008        Nov 5, 2008        Nov 6, 2008        Nov 7, 2008        Nov 8, 2008
Nov 9, 2008

i'm using the following as my external file to connect to the DBI which works fine since i've used it before:
Code:

#!/usr/bin/perl

$user_name = "username";
$user_password = "password";
$sql_server = "sql.useractive.com";

sub initialize_dbi
{
use DBI;
$drh = DBI->install_driver( 'mysql' );
$dbh = DBI->connect("DBI:mysql:username:sql.useractive.com",
'username', 'password');
die "Cannot connect: $D: $DBI::errstr\n"
unless $dbh;
}
sub run_statement
{
$stmt = "$_[0]";
$sth = $dbh->prepare($stmt);
$sth->execute;
}
sub parse_input
{
$whichmethod = $ENV{'REQUEST_METHOD'};
if($whichmethod eq "GET"){
$forminfo = $ENV{"QUERY_STRING"};
}else{
$forminfo = <STDIN>;
}

@key_value_pairs = split(/&/,$forminfo);
foreach $pair (@key_value_pairs){

($key,$value) = split(/=/,$pair);
$value =~ s/\+/ /g;
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C", hex($1))/eg;
$value =~ s/'/\\'/g;
$FORM_DATA{$key} = $value;
}
}
sub print_header
{
print "Content-type: text/html \n\n";

}
return true;

Thanks in advance for your help.


All times are GMT +5.5. The time now is 12:56.