use Encode; use CGI; use DBI; my $dbname="nanamizuki"; my $dbhost="your.database.host.addr"; my $dbuser="db user id"; my $dbpass="db password"; my $encstr = "utf-8"; my $cgi = CGI->new(); my $dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$dbhost",$dbuser,$dbpass) or die "cannot connect database."; my $sth = $dbh->prepare('SELECT id, tour_title FROM tours ORDER BY tour_start' ); my $id; my $tour_title; print $cgi->header({charset=>'utf-8'}); print $cgi->start_html( {title=>'Live List', charset=>'utf-8'} ); print $cgi->h1( {class=>"h1"}, "Live"); print $cgi->start_ol({}); $dbh->{AutoCommit}=0; $sth->execute(); $sth->bind_col( 1, \$id ); $sth->bind_col( 2, \$tour_title ); while( $sth->fetchrow_hashref() != undef ) { $id = encode($encstr, $id ); $tour_title = encode($encstr, $tour_title); print $cgi->li( $cgi->a({class=>'leftlink', href=>"b.cgi?id=$id"},$tour_title) ); } $sth->finish(); $dbh->commit(); print $cgi->end_ol(); print $cgi->end_html(); $dbh->disconnect();