Hi, I'm having a problem getting data to appear on a readout page. I have enclosed a copy of the script. I used this script before and it worked fine but now it only seems to want to present the pagination results, that is it shows the number of pages there should be (as to how many files should appear on a page) but I can't get the data itself to show. I know its opening the database because it is getting the number of records.
#!/usr/bin/perl
print"Content-type:text/html\n\n";
use DBI;
use CGI::Carp qw(fatalsToBrowser);
my(@pairs, $pair, $name, $value);
sub split_string
{
my ($string, $hash, $altdelim) = @_;
if($altdelim && $$string =~ m~;~) { @pairs = split(/;/, $$string); }
else { @pairs = split(/&/, $$string); }
foreach $pair (@pairs) {
($name,$value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if (exists($hash->{$name})) {
$hash->{$name} .= ", $value";
} else {
$hash->{$name} = $value;
}
}
}
split_string(\$ENV{QUERY_STRING}, \%INFO, 1);
if ($ENV{REQUEST_METHOD} eq 'POST')
{
read(STDIN, my $input, $ENV{CONTENT_LENGTH});
split_string(\$input, \%FORM)
}
#####
$dbusername="root";
$dbpwd="";
$dbname="cwk";
$dbhostname="localhost";
$dbtablename="prytmp";
#$database = "dbi:mysql:".$dbname.":".$dbhostname.":3306";
$database = "dbi:mysql:".$dbname.":".$dbhostname;
$dbh = DBI->connect($database,$dbusername,$dbpwd) or die "Can?t connect to the DB: $DBI::errstr\n";
$epp = "10";
$start = 0;
@results=($dbh->prepare("select * from tablename order by number limit $start,$epp"));
$start=0;
$sth=$dbh->prepare("select * from tablename order by number limit $start,$epp");
$num_rows= $dbh->selectrow_array('select COUNT(*) FROM tablename');
$info=$num_rows;
$num = $info;# total number or entries(based on counter
$start = $INFO{'start'} + 0;# number of the entry currently on top(0- first page,50 on the second, depends on $epp
if ($start > $info) { $start = $info - 1 }
elsif($start < 0) { $start = 0; }
$test=int(($start/$epp)+1);#number of currently shown page
$output='page: ';
for($k=0;$k<$num;$k+=$epp){
$pagenum = int(($k/$epp)+1);
if($test == $pagenum) {
$output .=" $pagenum"; #this is the page we're currently on
} else {
$newstart = ($pagenum - 1)*$epp; #this will be the start variable for the page we link to;
$output .=qq~ <a href="adpro.pl?start=$newstart">$pagenum</a>~;
$menu=$output;
}
}
################
print"<html>\n";
print" <head>\n";
print" <title>Read Requests</title>\n";
print" </head>\n";
print" <body>\n";
print" <table align=\"center\"width=\"90%\"cellpadding=\"4px\"cellspacing=\"4px\"border=\"4px\"bordercolor=\"gold\"valign=\"top\">\n";
print" <form method=\"post\"action=\"adpro2.pl\">\n";
$i = 0;#alt color line one
while($ref=$sth->fetchrow_hashref()){
$sth->execute();
$bgcolor = ($i++ & 1) ? '#ffccff' : '#ffffce'; #alt color line two#fofofo
print" <tr bgcolor='$bgcolor'>\n";
print" <td width=\"10%\"><p class=\"c\">Ok NA<br /><input type=\"radio\"name=\"approve_$ref->{'sub_num'}\"value=\"app\"> <input type=\"radio\"name=\"approve_$ref->{'number'}\"value=\"rej\"></p></td>\n";
print" <td width=\"90%\"border=\"6px\"bordercolor=\"gold\">\n";
print" <p>First Name: $ref->{'alias'} <br />\n";
print" Location: $ref->{'location'} <br />\n";
print" Email: <a href=mailto:$ref->{'email'}>$ref->{'email'} </a><br />\n";
print" Request: $ref->{'request'}</p>\n";
print" <input type=\"hidden\"name=\"epp\"value=\"$epp\">\n";
print" </td>\n";
print" </tr><tr>\n";
}
print" <td width=\"100%\"colspan=\"2\">\n";
print" <p class=\"c\"><input type=\"submit\"value=\"Process\">\n";
print" <br />$menu</p>\n";
print"</form>\n";
print" </table><br /><br />\n";
print" </body>\n";
print"</html>\n";