Advertisement
Guest User

Untitled

a guest
Jun 7th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php include("query.php"); ?>
  2.  
  3.  
  4. <select name="rua">
  5. <?php echo queryFunction("name"); ?>
  6. </select>
  7.  
  8. +++++++
  9. query.php:
  10.  
  11. <?php
  12. function queryFunction($table) {
  13. $connection = pg_connect(...);
  14. $query = "SELECT name FROM $table ORDER BY name ASC;";
  15. $results = pg_query($connection, $query);
  16. $rows = pg_num_rows($results);
  17. $string = "name";
  18.  
  19. for ($i=0; $i < $rows; $i++) {
  20. $string = $string . "<option>" . pg_fetch_result($results, $i, 0) . "</option>";
  21. }
  22.  
  23. return $string;
  24. }
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement