Your sql query will at some point return an error of being ambiguous or column with name, product not found. I have added aliases in the SQL query. If you do not understand. You can read up from here. https://www.w3schools.com/sql/sql_alias.asp
If you
Also try using mysqli because mysql is been deprecated as of PHP
5.5.0
$servername = "yourhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = (" SELECT customer.name AS name, customer.email AS email, customer.phone AS phone, product.product AS product_name, product.price AS price FROM customer, product WHERE customer.sl_no = product.sl_no AND customer. sl_no LIKE '%$search%' OR product. sl_no LIKE '%$search%' ");
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<strong>CUSTOMER</strong>";
echo "Customer Name: " . $row["name"]."<br>";
echo "Customer email: " . $row["email"]."<br>";
echo "Customer phone: " . $row["phone"]."<br>";
echo "----";
echo "<strong>PRODUCT</strong>";
echo "Product Name: " . $row["product_name"]."<br>";
echo "Product Price: " . $row["price"]."<br>";
echo "-----";
echo "----";
}
} else {
echo "0 results";
}
$conn->close();
Don't forget to first test or run query in the database via your
UI/phpmyadmin or CLI to understand what result you should expect.
Hope this helps.