Skip to content

Instantly share code, notes, and snippets.

@arif98741
Last active January 25, 2018 13:25
Show Gist options
  • Save arif98741/812745d966beccdf080bf033d63a1560 to your computer and use it in GitHub Desktop.
Save arif98741/812745d966beccdf080bf033d63a1560 to your computer and use it in GitHub Desktop.
Getting Data From Server By Go or Serial
<?php
//Code Written By Ariful Islam
//arif98741@gmail.com
//www.phpdark.com
//https://www.youtube.com/channel/UCMCe6bUMkxBP2dpsN0eSJ4g
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
form{ width: 60%; margin: 0 auto;}
input[type=text]{ width: 220px; height: 40px;}
input[type=submit]{ width: 70px; height: 40px;}
table{border:1px solid black; border-collapse: collapse; width: 80%; margin: 0 auto;}
td,th{padding: 10px; border: 1px solid black;}
td,th{text-align: center;}
tr{border: 1px solid #000}
tr:nth-child(2n){
background: #fbf5f5;
}
</style>
</head>
<body>
<form action="" method="GET">
<input type="text" name="query" placeholder="Search By Serial or Go Value" />
<input type="submit" value="Search" />
</form>
<br/><br/>
<table>
<thead>
<tr>
<th>No</th>
<th>Serial</th>
<th>Description</th>
<th>Go</th>
<th>No Go</th>
<th>Gauge Type</th>
<th>Location</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['query'])){
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "CSV_DB";
$con = new mysqli($host, $user, $pass, $db_name);
if($con){
$query = $_GET['query'];
if(empty($query)){
echo "<tr><td colspan='8'>Filed Must Not be Empty</td></tr>";
}else{
$sql = "SELECT * FROM inventory WHERE go = '$query' or serial = '$query'";
$stmt = $con->query($sql);
if($stmt) { $i = 0;
while($row = $stmt->fetch_assoc()) { $i++;?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row['serial'] ?></td>
<td><?php echo $row['description'] ?></td>
<td><?php echo $row['go'] ?></td>
<td><?php echo $row['no-go'] ?></td>
<td><?php echo $row['gague-type'] ?></td>
<td><?php echo $row['location'] ?></td>
</tr>
<?php } } } } } ?>
</tbody>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment