My Name Is Salman Masood , I am Computer Science &Amp; Maths Graduate from University of Karachi, Pakistan , Teaching Is My Passion and My Aim Is to Deliver All My Knowledge among Those Students Who Can'T Afford Tutors or Expensive Institute Fees. I Will Be Keep Sharing My All Knowledge and Information with You .... Remember Me in Your Prayers !
Friday, 28 September 2018
CRUD OPERATION IN PHP WITH MYSQLI PART 3
<!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>
Subscribe to:
Post Comments (Atom)
Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC
Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...
-
Load event: pictureBox3.Image = Image .FromFile( @"C:\Users\salman\Documents\Visual Studio 2013\Projects\WindowsFormsApplication3\W...
No comments:
Post a Comment