[[Perl]] http://nlp.kimura-s.otaru-uc.ac.jp/Perl/KeywordOtaruBlog.cgi #!/usr/bin/perl #DBI モジュールの読み込み use DBI; # データソースの指定 $dsn = 'DBI:mysql:データベース名:www:3306'; # データソース $dsn = 'DBI:mysql:データベース名'; # ユーザ名 $user = '*****'; # パスワード $password = '*****'; # データベースへ接続 $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 }); # prepareが成功した場合、ステートメントハンドルが返されます my $sth = $dbh->prepare( "SELECT * FROM テーブル名 LIMIT 0 , 100" ); # SQL文の実行 $sth->execute; print "Content-type: text/html\n\n"; print <<EOF; <html> <body> <ol> EOF # データの取得と出力 while(@row = $sth->fetchrow_array) { #print "@row\n"; print "<li>$row[2]</li><ul>\n"; for($i=0;$i<@row;$i++){ print "<li>$row[$i]</li>\n"; } print "</ul>"; } print <<EOF; </ol> </body> </html> EOF