Guest User

Untitled

a guest
Jun 7th, 2013
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $con = pg_connect("host=localhost dbname=aveiro port =5432 user=pedro password=****");
  4.  
  5. $query = "SELECT DISTINCT rua AS nome,n_rua AS id FROM ruas";
  6.  
  7. $result = pg_query($con,$query);
  8.  
  9. pg_close($con);
  10.  
  11. ?>
  12.  
  13.  
  14. <!DOCTYPE html>
  15. <html>
  16. <body>
  17.  
  18. <h1>Testes</h1>
  19.  
  20.  
  21.  
  22. <select name="rua">
  23.     <?php
  24.    while ($line = pg_fetch_array($result)) {
  25.        echo '<option value="' . $line['id'] . '">' . $line['nome'] . '</option>';
  26.     }
  27.     ?>
  28. </select>
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. </body>
  36. </html>
RAW Paste Data