What I mean is all my data are currently stored in phpMyAdmin and what I’m trying to accomplish is to search the value store by ID. Now, it is possible but after watching your PHP Code Along video , I want to include a button where I can delete the items straight away. The way how I add the database is just by searching it using ID so I just one to create a workable delete button. However, I’m not sure if it is possible to create a button directly through phpMyAdmin because if it is a text, then I have no problem but if it is a button, I’m not so sure about it
<html>
<head>
<link rel="stylesheet" href="css/booklist.css">
<title>Search data by its ID</title>
<script type="text/javascript">
function out(){
alert("Checkout Items Successful!");
}
</script>
</head>
<div class ="background">
<h1>Library Checkout System</h1>
<h2>Loan/Request Your Books Here</h2>
<form action="" method="POST">
<input type="text" name="id" placeholder="Please enter Book ID" />
<input type="submit" name="search" value="Search By ID" />
</form>
<table border="2" id="newton">
<tr>
<th>Product Name</th>
<th>Quantity</th>
<th>Returned Date</th>
</tr><br><br>
<?php
$connection = mysqli_connect("localhost","root", "");
$db = mysqli_select_db($connection,"myfirstdb");
session_start();
if (!isset($_SESSION['id'])) {
$_SESSION['id'] = array();
}
if(isset($_POST['search']))
{
$id = $_POST['id'];
array_push($_SESSION['id'],$id); //Here we have declared a session array. We can add elements to it by array_push function.//
$_SESSION['id'] = array_unique($_SESSION['id']); //array_unique: Removes duplicate values from an array
$id = implode(',',$_SESSION['id']); //implode : returns a strings from the elements of an array.//
// instead of changing the database of each row, the implode() function adds the rows according to the selected id entered.//
// this function is the key for solving my original problem.//
$query = "SELECT * FROM `table3` where id in ($id)";
$query_run = mysqli_query($connection, $query);
while($row = mysqli_fetch_array($query_run))
{
?>
<tr>
<td>
<?php echo $row ['product_name']; ?> </td>
<td>
<?php echo $row ['quantity']; ?> </td>
<td>
<?php echo $row ['returned_date']; ?> </td>
</tr>
<?php
}
}
?>
</table>
<br>
<input type="submit" name="send" value="Confirm Booklist" onclick="out()" />
</form>
</div>
</body>
</html>