SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | ||
3 | $dbhost = 'localhost'; | |
4 | ||
5 | $user = 'root'; | |
6 | ||
7 | $password = 'root'; | |
8 | ||
9 | $dbname = 'inventory'; | |
10 | ||
11 | $pdo = new PDO("mysql:host=$dbhost; $dbname", $user, $password); | |
12 | ||
13 | ||
14 | ?> | |
15 | ||
16 | <html> | |
17 | <head> | |
18 | <title>Inventory List</title> | |
19 | </head> | |
20 | <body> | |
21 | <?php | |
22 | include 'inventory.php'; | |
23 | ||
24 | $list = $pdo->query("SELECT year, make, model, color, price FROM cars ORDER BY price ASC"); | |
25 | ||
26 | $results = $list->fetchAll(PDO::FETCH_OBJ); | |
27 | ?> | |
28 | <table> | |
29 | <thead> | |
30 | <tr>Year</tr> | |
31 | <tr>Make</tr> | |
32 | <tr>Model</tr> | |
33 | <tr>Color</tr> | |
34 | <tr>Price</tr> | |
35 | </thead> | |
36 | ||
37 | <tbody> | |
38 | ||
39 | <tr> | |
40 | <?php foreach($results as $entry); ?> | |
41 | <td><?php echo $entry->year; ?></td> | |
42 | <td><?php echo $entry->make; ?></td> | |
43 | <td><?php echo $entry->model; ?></td> | |
44 | <td><?php echo $entry->color; ?></td> | |
45 | <td><?php echo $entry->price; ?></td> | |
46 | <td><a href="edit.php?id=<?php echo $entry->id; ?>">Edit</a> | |
47 | <a href="delete.php?id=<?php echo $entry->id; ?>">Delete</a></td> | |
48 | </tr> | |
49 | </tbody> | |
50 | </table> | |
51 | ||
52 | ||
53 | </body> | |
54 | </html> |