I am doing a library project to reserve books.Here, I search for a book and get the data on the database into a table using php.Here is the code.
$sql=" SELECT DISTINCT books.isbn,books.bname,books.bauthor,books.btype FROM books WHERE CONCAT(isbn, '', bname, '', bauthor, '', btype) LIKE '%" . $search . "%' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc())
{
?>
<tr>
<td><?php echo('<a href="bookres.php?[$bisb]='.$row['isbn'].'">'.$row['isbn'].'</a>');?></td>
<td><?php echo $row['bname']?></td>
<td><?php echo $row['bauthor']?></td>
<td><?php echo $row['btype']?></td>
</tr>
<?php
}
} else {
echo "0 results";
}
In the table,I have made the ISBN column clickable.
When I click on a books ISBN number, I need to display the clicked ISBN number on the reditected page.On the redirected page(bookres.php), I have written the following code.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$db = "vidunena";
if (mysqli_connect_error()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$bisb = "";
if(isset($_POST['bisb']))
{
$bisb = $_POST["bisb"];
}
echo $bisb;
?>
However, when I clich on an ISBN number, it,s being redirected to the given page but the ISBN number is not echoed in it.How can I fix this?