Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Auto Info</title>
- </head>
- <body>
- <table border="1">
- <tr><th>ID</th><th>Make</th><th>Model</th><th>Year</th><th>Owner</th><th>MSRP</th><th>Purchase Date</th></tr>
- <?php
- $conn = pg_connect("host=127.0.0.1 dbname=hillyerb_db user=hillyerb password=legend21" );
- $sql = "select make, model, year, msrp
- from auto_info
- order by year";
- $result = pg_query($conn, $sql);
- $records = pg_num_rows($result);
- for($i = 0; $i < $records; $i++){
- echo "nt<tr>ntt<td>".pg_fetch_result($result, $i, "id_num")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "make")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "model")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "year")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "owner")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "msrp")."</td>";
- echo "ntt<td>".pg_fetch_result($result, $i, "purchase_date")."</td>nt</tr>";
- }
- ?>
- </table>
- </body>
- </html>
- CREATE TABLE auto_info (
- id_num INTEGER PRIMARY KEY,
- make char(15) NOT NULL,
- model char(20) NOT NULL,
- year INTEGER NOT NULL,
- owner char(20) NOT NULL,
- msrp decimal(19,2) NOT NULL,
- purchase_date date NOT NULL
- );
- INSERT INTO auto_info(id_num, make, model, year, owner, msrp, purchase_date)
- VALUES(
- 2112,
- 'Tesla',
- 'Model S P100D',
- 2017,
- 'John Smith',
- 193900.00,
- '2017-01-03');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement