- 论坛徽章:
- 0
|
本帖最后由 蚊仔perlperl 于 2013-03-05 09:24 编辑
- #!/usr/bin/perl -w
- #
- #
- use strict;
- use CGI qw(:standard *table);
- use DBI;
- my $dbh=DBI->connect("DBI:mysql:host=192.168.5.129;database=test_db",
- "root",
- "123456",
- {PrintError=>0,RaiseError=>1}
- );
- my $sth=$dbh->prepare("SELECT * FROM test_tb");
- $sth->execute();
- #create cgi code.
- my $cgi=new CGI;
- print header(),
- start_html();
- while(my @val=$sth->fetchrow_array()){
- print table({-border=>undef},
- Tr({-align=>'CENTER',-valign=>'TOP'},
- [
- th(['uuiiuu','adeade','aswwwwww','fffaaaa', 'ageaasdaf','aasdafsdfh','aaar','abcd']),
- td([@val])
- ]
- )
- );
复制代码
得到这个样子的表格,好难看的,表格重复了,看了perldoc CGI 想不到从哪里入手。请前辈指教,谢谢。 |
|