#!/usr/bin/perl use DBI; use CGI; $param=new CGI; $tabulka = $param ->param('table'); print "Content-type:text/html\n\n"; &init; print ""; if ($tabulka) { $dbh = DBI->connect("$INIT","$LOGIN","$PASS"); $pop = $dbh->prepare("show columns from $tabulka"); $pop->execute; $sth=$dbh->prepare("select * from $tabulka LIMIT 1"); $sth->execute; @sloupce = @{$sth->{NAME}}; print qq(Selected table : $tabulka
\n); print qq(
); print qq(
); @rr=$sth->fetchrow_array; $cnt=0; foreach $ra(@sloupce) { @types=$pop->fetchrow_array; print qq(\n); if($types[5]=~/auto/){$defo="null"}else{$defo=""}; if (($types[1]=~/text/)||($types[1]=~/blob/)) { print qq(\n); }else { print qq(\n); } $cnt++; } print qq(
Submit :
columns : @sloupce
$ra $types[1]
Submit :
); $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"; }