Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Auto Info</title>
  4. </head>
  5. <body>
  6.  
  7. <table border="1">
  8. <tr><th>ID</th><th>Make</th><th>Model</th><th>Year</th><th>Owner</th><th>MSRP</th><th>Purchase Date</th></tr>
  9.  
  10. <?php
  11. $conn = pg_connect("host=127.0.0.1 dbname=hillyerb_db user=hillyerb password=legend21" );
  12.  
  13. $sql = "select make, model, year, msrp
  14. from auto_info
  15. order by year";
  16. $result = pg_query($conn, $sql);
  17. $records = pg_num_rows($result);
  18.  
  19.  
  20. for($i = 0; $i < $records; $i++){
  21. echo "nt<tr>ntt<td>".pg_fetch_result($result, $i, "id_num")."</td>";
  22. echo "ntt<td>".pg_fetch_result($result, $i, "make")."</td>";
  23. echo "ntt<td>".pg_fetch_result($result, $i, "model")."</td>";
  24. echo "ntt<td>".pg_fetch_result($result, $i, "year")."</td>";
  25. echo "ntt<td>".pg_fetch_result($result, $i, "owner")."</td>";
  26. echo "ntt<td>".pg_fetch_result($result, $i, "msrp")."</td>";
  27. echo "ntt<td>".pg_fetch_result($result, $i, "purchase_date")."</td>nt</tr>";
  28. }
  29. ?>
  30. </table>
  31. </body>
  32. </html>
  33.  
  34. CREATE TABLE auto_info (
  35. id_num INTEGER PRIMARY KEY,
  36. make char(15) NOT NULL,
  37. model char(20) NOT NULL,
  38. year INTEGER NOT NULL,
  39. owner char(20) NOT NULL,
  40. msrp decimal(19,2) NOT NULL,
  41. purchase_date date NOT NULL
  42. );
  43.  
  44. INSERT INTO auto_info(id_num, make, model, year, owner, msrp, purchase_date)
  45. VALUES(
  46. 2112,
  47. 'Tesla',
  48. 'Model S P100D',
  49. 2017,
  50. 'John Smith',
  51. 193900.00,
  52. '2017-01-03');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement