1<?php
2 $con= new mysqli("localhost","root","","Employee");
3 $name = $_post['search'];
4 //$query = "SELECT * FROM employees
5 // WHERE first_name LIKE '%{$name}%' OR last_name LIKE '%{$name}%'";
6
7 // Check connection
8 if (mysqli_connect_errno())
9 {
10 echo "Failed to connect to MySQL: " . mysqli_connect_error();
11 }
12
13$result = mysqli_query($con, "SELECT * FROM employees
14 WHERE first_name LIKE '%{$name}%' OR last_name LIKE '%{$name}%'");
15
16while ($row = mysqli_fetch_array($result))
17{
18 echo $row['first_name'] . " " . $row['last_name'];
19 echo "<br>";
20}
21 mysqli_close($con);
22 ?>
1$result = mysqli_query($con, "SELECT * FROM employees
2 WHERE first_name LIKE '%{$name}%' OR last_name LIKE '%{$name}%'");
3
4while ($row = mysqli_fetch_array($result))
5{
6 echo $row['first_name'] . " " . $row['last_name'];
7 echo "<br>";
8}
9 mysqli_close($con);
10 ?>