#!/usr/bin/perl
use DBI;
use CGI;
$param=new CGI;
$tabulka = $param ->param('table');
$radka = $param ->param('radka');
$id = $param ->param('id');
print "Content-type:text/html\n\n";
&init;
print "
";
if ($tabulka&&$radka&&$id)
{
$dbh = DBI->connect("$INIT","$LOGIN","$PASS");
$pop = $dbh->prepare("show columns from $tabulka");
$pop->execute;
$vysl =$radka/1;
if(!$vysl)
{
$sth=$dbh->prepare("select * from $tabulka where $id like '$radka'") || print $dbh->errstr;
}else
{
$sth=$dbh->prepare("select * from $tabulka where $id=$radka") || print $dbh->errstr;
}
$sth->execute;
@sloupce = @{$sth->{NAME}};
#@aaa = @{$sth->{TYPE}};
print qq(Selected table : $tabulka
\n);
print qq(
);
$sth->finish;
$pop->finish;
$dbh->disconnect;
}
# -------------------------------------------------
sub init
{
open(F,"dat.conf");
@o =;
close(F);
%COLS=();
foreach $radek (@o)
{
next if $radek=~/^#/; next unless $radek=~/\S/;
if ($radek=~/^init/i) {($INIT)=($radek=~/^init\s*=\s*(\S*)/i);};
if ($radek=~/^login/i) {($LOGIN)=($radek=~/^login\s*=\s*(\S*)/i);};
if ($radek=~/^pass/i) {($PASS)=($radek=~/^pass\s*=\s*(\S*)/i);};
#if ($radek=~/^tables/i) {($tmp)=($radek=~/^tables\s*=\s*(.*)/i);$tmp=~s/\s*//g;@TABL=split(",",$tmp);};
#if ($radek=~/^cols/i) {($tmp1,$tmp2)=($radek=~/^cols\s*(.*?)\s*=\s*(.*)/i);$tmp2=~s/\s*//g;$tmp2=~s/,/,/g;$COLS{"$tmp1"}="$tmp2";};
}
if(!$INIT) {&err("100","No init string");exit(0);}
}
sub err
{
print "
Error :$_[0] : $_[1]\n";
}