VIDEO
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
table,th
{
text-align: center;
}
td
{
padding: 10px;
}
</style>
</head>
<body>
<div class="col-lg-12 col-md-12 col-sm-12" style="height: 200px;">
<form method="post">
<table>
<tr>
<td> Book Name</td>
<td> <input type="text" name="book" class="form-control" placeholder="Book Name"></td>
</tr>
<tr>
<td> Book Price</td>
<td> <input type="text" name="price" class="form-control" placeholder="Book Price"></td>
</tr>
<tr>
<td> <input type="submit" name="btnAdd" class="btn btn-info"> </td>
</tr>
</table>
</form>
</div>
<?php
include 'includes/connection.php';
if (isset($_POST['btnAdd']))
{
$book=$_POST['book'];
$price=
$_POST['price'];
$sql ="INSERT INTO `tbl_book`( `BOOK_NAME`, `BOOK_pirce`) VALUES (?,?)";
$stmt=$conn->prepare($sql);
if (!$stmt)
{
echo "<script>alert('failed to insert data.....'); </script>";
}
else
{
$stmt->bind_param('ss',$book,$price);
$stmt->execute();
$stmt->close();
}
} // button event ends here.........................................................
$sqlquery="SELECT * FROM `tbl_book` ";
if($result=mysqli_query($conn,$sqlquery))
{
echo '<table class="table table-bordered table-responsive table-striped">';
echo "<thead>
<tr>
<th>ID </th>
<th>NAME </th>
<th>PRICE </th>
</tr>
</thead> ";
while ($row= mysqli_fetch_assoc($result))
{
echo "<tr> <td>". $row["BOOK_ID"]." </td> <td>". $row["BOOK_NAME"]." </td> <td>".$row["BOOK_pirce"]." </td> </tr>";
}
echo "</table>";
mysqli_free_result($result);
}
else
{
# code...
}
mysqli_close($conn);
?>
</body>
</html>