Mercurial > hg > extraction-interface
comparison _xampp/contrib/postgresql.php @ 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 <html> | |
2 <head> | |
3 <title>PHP und PostgreSQL</title> | |
4 </head> | |
5 <body> | |
6 <h1>PHP und PostgreSQL</h1> | |
7 <table border="1"> | |
8 <tr> | |
9 <th>Interpret</th> | |
10 <th>Titel</th> | |
11 <th>Jahr</th> | |
12 </tr> | |
13 <?php | |
14 | |
15 $conn_string = "host=localhost port=5432 dbname=cdcol | |
16 user=oswald password=geheim"; | |
17 | |
18 $db_handle = pg_connect($conn_string); | |
19 if(!$db_handle) | |
20 die("Kann Datenbank nicht erreichen!"); | |
21 | |
22 $query = "SELECT * FROM cds"; | |
23 | |
24 $result = pg_exec($db_handle, $query); | |
25 | |
26 if (!$result) | |
27 { | |
28 echo pg_errormessage($db_handle); | |
29 } | |
30 else | |
31 { | |
32 for ($row = 0; $row < pg_numrows($result); $row++) | |
33 { | |
34 $values = pg_fetch_array($result, $row, PGSQL_ASSOC); | |
35 echo "<tr>"; | |
36 echo "<td>".$values['interpret']."</td>"; | |
37 echo "<td>".$values['titel']."</td>"; | |
38 echo "<td>".$values['jahr']."</td>"; | |
39 echo "</tr>"; | |
40 } | |
41 } | |
42 ?> | |
43 </table> | |
44 </body> | |
45 </html> |