SEARCH RECORD FROM DATABASE BY PHP ON WEBPAGE
1. SEARCH RECORD
(search.php)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Search Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1">
<link rel="stylesheet"
href="style.css">
</head>
<body>
<div class="container">
<form class="form-inline" method="post"
action="">
<input type="text" name="eid"
class="form-control" placeholder="Employee ID">
<button type="submit" name="save" class="btn
btn-primary">Search</button>
</form>
</div>
</body>
</html>
<?php
error_reporting(0);
$con =
mysqli_connect("localhost","root","","pan1");
if(count($_POST)>0) {
$eid=$_POST[eid];
$result = mysqli_query($con,"SELECT *
FROM emp where eid='$eid' ");
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Retrive data</title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<td>Employ ID</td>
<td>Employee Name</td>
<td>City</td>
</tr>
<?php
$i=0;
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo
$row["eid"]; ?></td>
<td><?php echo
$row["ename"]; ?></td>
<td><?php echo
$row["city"]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</body>
</html>
0 Comments