Препараты
Однокомпонентные гомеопатические лекарственные средства производства "OOO ДОКТОР Н".
|
#!/usr/bin/perl -w
use DBI;
print "Content-Type: text/html\n\n";
$record=15;
$forward=0;
$back=0;
$num = 0;
$table="sostavpart";
$dbh= DBI->connect("DBI:mysql:homeo-apte_dn:homeo-apte.mysql","homeo-apte_mysql","8lj3bhlx") ||
die "Got error $DBI::errstr when connecting to $dsn\n";
$sth = $dbh->prepare("SET NAMES cp1251") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
print "";
$my_query_string = $ENV{'QUERY_STRING'};
#print "MY $my_query_string ";
if ($my_query_string ne "")
{
@pairs = split(/&/,$my_query_string);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ s/%([a-fA-Fа-яА-Я0-9][a-fA-Fа-яА-Я0-9])/pack("c",hex($1))/eg;
if ($name eq "number")
{
$form{number} = $value;
}
if ($name eq "all")
{
$form{all} = $value;
}
}
#print "Number $form{number} ";
$num=$form{number};
$all=$form{all};
#print "ALL $all ";
$sth = $dbh->prepare("SELECT * FROM $table LIMIT $num,$record") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
while ( @row = $sth->fetchrow_array )
{
out_form()
}
$sth->finish;
}
else
{
$sth = $dbh->prepare("SELECT * FROM $table where id<10000") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
$rv = $sth->rows;
$all=$rv;
#print "ALL $all ";
$sth->finish;
$num = 0;
$sth = $dbh->prepare("SELECT * FROM $table LIMIT $num,$record") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
while ( @row = $sth->fetchrow_array )
{
out_form()
}
$sth->finish;
}
$dbh->disconnect;
$form{number}=0;
#$forward=$num+20;
$forward=$num+$record;
#$back=$num-20;
$back=$num-$record;
#if (($forward le $all) && ($back ge 0))
if (($forward <= $all) && ($back >= 0))
{
print "<< Назад";
print "";
print "Далее >> | ";
}
# elsif ($back lt 0)
elsif ($back < 0)
{
print "Далее >> | ";
}
# elsif ($forward gt $all)
elsif ($forward > $all)
{
print "<< Назад | ";
}
print " ";
Apache::exit();
sub out_form
{
print " | $row[1] ";
if ($row[2] ne "")
{ print "$row[2] "; }
if ($row[3] ne "")
{ print "$row[3] "; }
if ($row[4] ne "")
{ print "$row[4] "; }
if ($row[5] ne "")
{ print "$row[5] "; }
if ($row[6] ne "")
{ print "$row[6] "; }
if ($row[7] ne "")
{ print "$row[7] "; }
if ($row[8] ne "")
{ print "$row[8] "; }
if ($row[9] ne "")
{ print "$row[9] "; }
if ($row[10] ne "")
{ print "$row[10] "; }
if ($row[11] ne "")
{ print "$row[11] "; }
print " | ";
}
|
|