-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbex.php
51 lines (37 loc) · 1.08 KB
/
dbex.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
<!doctype html>
<html>
<head>
<title>php db ex</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h1> php example </h1>
<?php //create/check connection
$servername = "localhost";
$username = "root";
$password = "123angelo1";
$dbname = "sbuxdto";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
////////////////////////////////////////////////
//$sql = "SELECT id, firstname, lastname FROM MyGuests";
$sql = "SELECT drinkName, tallCost, hotCold FROM drinklist";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Drink: " . $row["drinkName"]. " - Cost of Tall Size: $" . $row["tallCost"]. " " . $row["hotCold"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html >