-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_products.php
56 lines (48 loc) · 1.26 KB
/
list_products.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Created by PhpStorm.
* User: MKochanski
* Date: 7/24/2018
* Time: 3:07 PM
*/
require_once 'config.inc.php';
?>
<html>
<head>
<title>Sample PHP Database Program</title>
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<?php
require_once 'header.inc.php';
?>
<div>
<h2>Product Catalog</h2>
<?php
// Create connection
$conn = new mysqli($servername, $username, $password, $database, $port);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare SQL
$sql = "SELECT ItemNumber,ItemDescription,CategoryCode FROM catalogitem";
$stmt = $conn->stmt_init();
if (!$stmt->prepare($sql)) {
echo "failed to prepare";
}
else {
// Execute Statement
$stmt->execute();
// Process Results using Cursor
$stmt->bind_result($itemNumber,$description, $category_code);
while ($stmt->fetch()) {
echo "<p>" . $description . "</p>";
}
}
$conn->close();
?>
</div>
</body>
</html>