Гомеопатические препараты
Указатель-путеводитель. |
#!/usr/bin/perl -w
use DBI;
print "Content-Type: text/html\n\n";
$record=80;
$forward=0;
$back=0;
$num = 0;
$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'};
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;
}
if ($name eq "prep")
{
$form{prep} = $value;
}
if ($name eq "dis")
{
$form{dis} = $value;
}
}
if (($form{prep} ne "no") && ($form{dis} eq "no") && ($form{number} eq "no") && ($form{all} eq "no"))
{
if ($form{prep} eq "10000")
{ print "О кремах, выпускаемых нашей аптекой, Вы можете узнать в разделе \"Косметика ДН\" | ";
} else
{
#print "PREP2";
$sth = $dbh->prepare("SELECT * FROM dn_preparate WHERE id='$form{prep}'") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
while ( @row = $sth->fetchrow_array )
{
form_prep();
}
}
print "
Указатель-путеводитель | ";
$form{prep}="";
$sth->finish;
}
elsif (($form{dis} ne "no") && ($form{prep} eq "no") && ($form{number} eq "no") && ($form{all} eq "no"))
{
# print "DIS1";
print "$form{dis} | ";
$sth = $dbh->prepare("SELECT dn_preparate.* FROM diseases, dn_preparate WHERE diseases.name='$form{dis}' AND dn_preparate.id=diseases.preparate_id") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
while ( @row = $sth->fetchrow_array )
{
form_prep();
}
print "
Указатель-путеводитель | ";
$sth->finish;
$form{dis}="";
}
elsif (($form{number} ne "no") && ($form{all} ne "no") && ($form{dis} eq "no") && ($form{prep} eq "no"))
{
#print "NUMBER2; ALL2";
$num=$form{number};
$all=$form{all};
print "Заболевание | ";
print "Гомеопатический препарат | ";
$sth = $dbh->prepare("SELECT * FROM diseases LIMIT $num,$record") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
$old="";
while ( @row = $sth->fetchrow_array )
{
out_form()
}
$sth->finish;
menu();
$form{number}="";
}
}
else
{
#print "END";
$sth = $dbh->prepare("SELECT * FROM diseases where id<10000") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
$rv = $sth->rows;
$all=$rv;
$sth->finish;
$num = 0;
print "Заболевание | ";
print "Гомеопатический препарат | ";
$sth = $dbh->prepare("SELECT * FROM diseases LIMIT $num,$record") or die $mysql::db_errstr;
$sth->execute or die "Unable_to_execute";
$old="";
while ( @row = $sth->fetchrow_array )
{
out_form()
}
$sth->finish;
menu();
}
$dbh->disconnect;
print " ";
Apache::exit();
sub out_form
{
if ($row[4] ne "")
{
print " | - $row[4] - | ";
}
else
{
if ($old ne $row[1])
{
$old=$row[1];
$disrow = $row[1];
$disrow =~ s/ /%20/g;
print "$row[1] | ";
} elsif ($old eq $row[1]) {
print "
---|
";
}
if ($row[2] ne "")
{
print " | $row[2] | ";
}
}
}
sub menu
{
$form{number}=0;
$forward=$num+$record;
$back=$num-$record;
if (($forward <= $all) && ($back >= 0))
{
print " << Назад";
print "";
print "Далее >> | ";
}
elsif ($back < 0)
{
print " Далее >> | ";
}
elsif ($forward > $all)
{
print " << Назад | ";
}
}
sub form_prep
{
print "$row[1] | ";
if ($row[3] ne "")
{ print "$row[3] | "; }
if ($row[2] ne "")
{ print "Лекарственная форма $row[2] | "; }
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 "
| ";
}
|
|