Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. connection.inc
  2. <?php
  3.  
  4. $info = "host=localhost dbname=db_b090904cs user=b090904cs password=roflcopter";
  5. $conn = pg_connect($info);
  6.  
  7. if(!$conn)
  8. {
  9.     echo "Couldn't Connect To DB";
  10.     exit;
  11. }
  12.  
  13. ?>
  14.  
  15. page.php
  16.  
  17. <html>
  18. <head>
  19. <title>Hotel Project</title>
  20. </head>
  21.  
  22. <body>
  23. <?php
  24.  
  25. require("connection.php");
  26.  
  27. $query = "SELECT * FROM RoomType";
  28. $result = pg_query($conn, $query);
  29. if (!$result)
  30. {
  31.     echo "No result..";
  32.     exit;
  33. }
  34. echo "<br />";
  35. echo "
  36. <table border=1>
  37. <tr>
  38. <th>TypeID</th>
  39. <th>Class</th>
  40. <th>View</th>
  41. <th>CapAdult</th>
  42. <th>CapChild</th>
  43. </tr> ";
  44.  
  45. while ($row = pg_fetch_array($result))
  46. {
  47.     echo "<tr>";
  48.     echo "<td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td></tr>";
  49. } ;
  50. echo "</table>";
  51. ?> <br />
  52. <form>
  53. <select name = "test">
  54. <?
  55. $res = pg_query($conn, $query);
  56. while ($r1 = pg_fetch_array($res))
  57. {
  58.     echo "<option>".$r1[0]."</option>";
  59. };
  60. ?>
  61. </select><br/>
  62. <input type = "submit" />
  63. </form>
  64. <?
  65. /*
  66.    $arr = pg_fetch_all($result);
  67.    print_r($arr);
  68.  */
  69. pg_close();
  70. ?>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement