0% found this document useful (0 votes)
3 views2 pages

p

Uploaded by

anuragrana5122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

p

Uploaded by

anuragrana5122
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php
include "navbar.php";
include "connection.php"
?>
<!DOCTYPE html>
<html>
<head>
<title>Books</title>
<style type="text/css">
.srch
{
padding-left:1000px ;
}
</style>
</head>
<body>
<!---______________________________________Search
Bar_________________________________-->

<div class="srch">
<from class="navbar-form" method="post" name="form1">

<input class="form-control" type="text" name="search"


placeholder="search book.." required="">
<button style="background-color: #002147;" type="submit"
name="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</from>
</div>

<h2><u>List of Books</u></h2>
<?php

if(isset($_POST['submit']))
{
$q=mysqli_query($db,"SELECT * from books where name like '%
$_POST[search]%' ");

if(mysqli_num_rows($q)==0)
{
echo "Sorry! No book found. Try searching again.";
}
else
{
echo "<table class='table table-bordered table-hover'>";
echo "<tr style='background-color:#002147;'>";
//Table header
echo "<th style='color:white;'>"; echo "ID"; echo "</th>";
echo "<th style='color:white;'>"; echo "Books-Name"; echo "</th>";
echo "<th style='color:white;'>"; echo "Authors Name"; echo
"</th>";
echo "<th style='color:white;'>"; echo "Edition"; echo "</th>";
echo "<th style='color:white;'>"; echo "Status"; echo "</th>";
echo "<th style='color:white;'>"; echo "Quantity"; echo "</th>";
echo "<th style='color:white;'>"; echo "Department"; echo "</th>";
echo "</tr>" ;

while($row=mysqli_fetch_assoc($q))
{
echo "<tr>";
echo "<td>"; echo $row['bid']; echo "</td>";
echo "<td>"; echo $row['name']; echo "</td>";
echo "<td>"; echo $row['authors']; echo "</td>";
echo "<td>"; echo $row['edition']; echo "</td>";
echo "<td>"; echo $row['status']; echo "</td>";
echo "<td>"; echo $row['quantity']; echo "</td>";
echo "<td>"; echo $row['department']; echo "</td>";

echo"</tr>";
}
echo "</table>";
}
}
/*if butthon is not pressed.*/
else
{
$res=mysqli_query($db,"SELECT * FROM `books` ORDER BY
`books`.`name` ASC;");

echo "<table class='table table-bordered table-hover'>";


echo "<tr style='background-color:#002147;'>";
//Table header
echo "<th style='color:white;'>"; echo "ID"; echo "</th>";
echo "<th style='color:white;'>"; echo "Book-Name"; echo "</th>";
echo "<th style='color:white;'>"; echo "Authors Name"; echo "</th>";
echo "<th style='color:white;'>"; echo "Edition"; echo "</th>";
echo "<th style='color:white;'>"; echo "Status"; echo "</th>";
echo "<th style='color:white;'>"; echo "Quantity"; echo "</th>";
echo "<th style='color:white;'>"; echo "Department"; echo "</th>";
echo "</tr>" ;

while ($row=mysqli_fetch_assoc($res))
{
echo "<tr>";
echo "<td>"; echo $row['bid']; echo "</td>";
echo "<td>"; echo $row['name']; echo "</td>";
echo "<td>"; echo $row['authors']; echo "</td>";
echo "<td>"; echo $row['edition']; echo "</td>";
echo "<td>"; echo $row['status']; echo "</td>";
echo "<td>"; echo $row['quantity']; echo "</td>";
echo "<td>"; echo $row['department']; echo "</td>";

echo"</tr>";
}
echo "</table>";
}

?>
</body>
</html>

You might also like