Mercurial > hg > extraction-interface
comparison _xampp/contrib/mysql.pl @ 0:b12c99b7c3f0
commit for previous development
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 19 Jan 2015 17:13:49 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b12c99b7c3f0 |
---|---|
1 #!/opt/lampp/bin/perl | |
2 use DBI; | |
3 | |
4 print "Content-Type: text/html\n\n"; | |
5 | |
6 my $dsn="dbi:mysql:phonebook:localhost"; | |
7 my $dbh=DBI->connect("$dsn","oswald","geheim") or | |
8 die "Kann Datenbank nicht erreichen!"; | |
9 | |
10 print "<html>"; | |
11 print "<head>"; | |
12 print "<title>Perl und MySQL</title>"; | |
13 print "</head>"; | |
14 print "<body>"; | |
15 print "<h1>Perl und MySQL</h1>"; | |
16 print "<table border=\"1\">"; | |
17 print "<tr>"; | |
18 print "<th>Vorname</th>"; | |
19 print "<th>Nachname</th>"; | |
20 print "<th>Telefonnummer</th>"; | |
21 print "</tr>"; | |
22 | |
23 my $query="SELECT * FROM users"; | |
24 | |
25 my $prep_sql=$dbh->prepare($query) or die print "Can't prepare"; | |
26 $prep_sql->execute() or die print "Can't execute"; | |
27 | |
28 while (my @row = $prep_sql->fetchrow_array()) | |
29 { | |
30 print "<tr>"; | |
31 print "<td>".$row[1]."</td>"; | |
32 print "<td>".$row[2]."</td>"; | |
33 print "<td>".$row[3]."</td>"; | |
34 print "</tr>"; | |
35 } | |
36 | |
37 $prep_sql->finish(); | |
38 $dbh->disconnect(); | |
39 | |
40 print "</table>"; | |
41 print "</body>"; | |
42 print "</html>"; |