HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width=device-width, initial scale = 1.0">
<link rel="stylesheet" type="text/css" href="css/booklist.css">
<title>Library Book Catalogue</title>
</head>
<body>
<h1>Library System</h1>
<div id="header">
<h2 style="padding: 10px; font-family:Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif ;">The Readers Plane</h2>
</div>
<div class = "book-list">
<form method ="POST" action="php2/num10.php">
<table>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Availability</th>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/oxford.jpeg">
<div>
<h3>Oxford Dictionary of Idioms</h3>
<p>Price : RM48.90</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/python.jpeg">
<div>
<h3>Python Programming</h3>
<p>Price : RM62.90</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/recipe.jpeg">
<div>
<h3>What Mummy Makes</h3>
<p>Price : RM41.50</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/chemical.jpg">
<div>
<h3>Introductory Chemical Engineering Thermodynamics</h3>
<p>Price : RM124.70</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/a&f.jpg">
<div>
<h3>Finance and Accounting: An Introduction</h3>
<p>Price : RM124.70</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/electrical.jpg">
<div>
<h3>Electrical Engineering Textbook</h3>
<p>Price : RM112.80</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/record.jpeg">
<div>
<h3>Guinness World Records 2021</h3>
<p>Price : RM43.30</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/steven.jpeg">
<div>
<h3>Steven Gerrard: My Story</h3>
<p>Price : RM35.00</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/pharma.jpg">
<div>
<h3>Pharmacology: A Patient-Centered Nursing Process Approach</h3>
<p>Price : RM155.00</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="">Add to Borrow List</button></td>
</tr>
<tr>
<td>
<div class = "features">
<img src = "img/cs.jpg">
<div>
<h3>Computer Science: An Overview, Global Edition</h3>
<p>Price : RM111.90</p>
</div>
</div>
</td>
<td><input type="number" value="1"></td>
<td><button type="submit" onclick="" id="" value="">Add to Borrow List</button></td>
</tr>
</table>
</form>
</div>
</body>
</html>
PHP Code
<?php
require "num1.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practical 10</title>
<style>
table {
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
border: 1px solid black;
}
th:first-of-type,
td:first-of-type {
text-align: center;
width: 20px;
}
th:not(:first-of-type),
td:not(:first-of-type) {
padding-left: 10px;
padding-right: 10px;
}
</style>
</head>
<body>
<h1>Student Records</h1>
<table>
<tr>
<th>#</th>
<th>Product Name</th>
<th>Quantity</th>
<th>Returned Date</th>
</tr>
<?php
$sql = "SELECT * FROM `table3`;";
$sql_run = $conn->query($sql); // contain SQL results, FALSE if there's an error
if($sql_run) { // if it is not false, then proceed
if($sql_run->num_rows > 0) { // num_rows will check if there are row(s) of results
while($row = $sql_run->fetch_assoc()) {
?>
<tr>
<td><?= $row['id']; ?></td>
<td><?= $row['product_name']; ?></td>
<td><?= $row['quantity']; ?></td>
<td><?= $row['returned_date']; ?></td>
</tr>
<?php
}
} else
echo "No table rows found.";
} else
echo "Error retrieving table rows: " . $conn->error;
?>
</table>
</body>
</html>
My database are all connected to phpMyAdmin. I am able to display the database but not one by one. I want a particular item to be added to the database based on the row of each item as each row has a particular button to be added to the database.