-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist.php
57 lines (53 loc) · 1.35 KB
/
list.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
57
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "iwp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM bookstable";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
echo"<style>
td{
font-size: 30px;
}
h1{
margin-top: 40px;
}
table{
margin-top: 50px;
width:1000px;
border-collapse:collapse;
border: 2px double black;
text-align:center;
font-family:times;}
tr:nth-child(odd) {background-color: #ABC81F;}
</style>";
echo"<center><h1>Books Available</h1></center>";
echo "<center><table>
<tr>
<td>BOOK TITLE</td>
<td>Author name</td>
<td>Quantity</td>
<td>Topic</td>
</tr>";
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>". $row["BOOK_TITLE"]. "</td>
<td>". $row["AUTHOR_NAME"]. "</td>
<td>" . $row["QUANTITY"] . "</td>
<td>" . $row["TOPIC"] . "</td></tr>";
}
echo "</table></center>";
} else {
echo "0 results";
}
echo '<button><a href="user.html">Go back</button>';
$conn->close();
?>