-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathread.php
More file actions
52 lines (38 loc) · 1.38 KB
/
read.php
File metadata and controls
52 lines (38 loc) · 1.38 KB
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
<?php require "templates/header.php"; ?>
<div class="center-align">
<?php
require "database/config.php";
//Establish the connection
$conn = mysqli_init();
mysqli_ssl_set($conn,NULL,NULL,$sslcert,NULL,NULL);
if(!mysqli_real_connect($conn, $host, $username, $password, $db_name, 3306, MYSQLI_CLIENT_SSL)){
die('Failed to connect to MySQL: '.mysqli_connect_error());
}
//Test if table exists
$res = mysqli_query($conn, 'SELECT * FROM software_list');
if (mysqli_num_rows($res) <= 0) {
echo "<h2>Catalog is empty.</h2>";
}
else {
echo "<table> <tr align=\"left\"> <th> Product Name </th> <th> Price (USD) </th> </tr>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr align=\"left\"> <td> ".$row["ProductName"]." </td>";
echo "<td> ".$row["Price"]." </td> </tr>";
}
echo "</table>";
}
}
//Close the connection
mysqli_close($conn);
?>
<br> <br> <br>
<table>
<tr>
<td> <a href="insert.php">Add a Product</a> </td>
<td> <a href="update.php">Update a Product</a> </td>
<td> <a href="delete.php">Remove a Product</a> </td>
<td> <a href="index.php">Back to Home Page</a> </td>
</tr>
</table>
</div>
<?php require "templates/footer.php"; ?>