Advertisement
Guest User

conectando

a guest
Apr 5th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2.  
  3. $bdcon = pg_connect("host=200.137.66.7 port=5432 dbname=bocadb user=postgres password=123456") or die('connection failed: '. pg_last_error());
  4.  
  5. $query = 'SELECT * FROM usertable';
  6. $result = pg_query($query) or die('Query failed: ' . pg_last_error());
  7.  
  8. echo "<table>\n";
  9. while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
  10.     echo "\t<tr>\n";
  11.     foreach ($line as $col_value) {
  12.         echo "\t\t<td>$col_value</td>\n";
  13.     }
  14.     echo "\t</tr>\n";
  15. }
  16. echo "</table>\n";
  17.  
  18. pg_free_result($result);
  19. pg_close($bdcon);
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement