Posted By

limonn on 10/26/06


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

letosword


codigo para postgresql


 / Published in: PHP
 

nueva base de datos postgresql

  1. <?php
  2.  
  3. $dbconn = pg_connect("host=localhost dbname=test user=postgres password=laclave")
  4. or die('Could not connect: ' . pg_last_error());
  5.  
  6.  
  7. // Performing SQL query
  8. $query = 'SELECT * FROM person';
  9. $result = pg_query($query) or die('Query failed: ' . pg_last_error());
  10.  
  11.  
  12. // Printing results in HTML
  13. echo "<table>\n";
  14. while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
  15. echo "\t<tr>\n";
  16. foreach ($line as $col_value) {
  17. echo "\t\t<td>$col_value</td>\n";
  18. }
  19. echo "\t</tr>\n";
  20. }
  21. echo "</table>\n";
  22.  
  23. // Free resultset
  24. pg_free_result($result);
  25.  
  26. // Closing connection
  27. pg_close($dbconn);
  28. //echo "col_value=".$col_value."result=".$result;
  29. ?>

Report this snippet  

You need to login to post a comment.