Simple Search System Not Working PHP SQL HTML : <p>So I'm new to SQL, PHP and HTML. I'm trying to create a search system for my database that contains a table for foods and their prices. I've searched everywhere for people who have the same problem as me but none of the solutions seem to help me. </p>

<p>I've searched far and wide over all the forums I could find, loads of tutorials on YouTube yet to no avail.</p>

<p>Main PHP code:</p>

<pre><code>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset = "utf-8"&gt;
&lt;title&gt;Lists of foods and prices! Input yours here!&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Insert your fav food!&lt;/h1&gt;

&lt;table&gt;
&lt;form action = "" method = "post"&gt;
&lt;tr&gt;
&lt;td&gt;Food: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Food"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price: &lt;/td&gt;&lt;td&gt;&lt;input type="integer" name="Price"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supermarket: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Supermarket"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="submit" name = "submit"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;/form&gt;
&lt;/table&gt;

&lt;table&gt;
&lt;form action = "" method = "post"&gt;
&lt;tr&gt;
&lt;td&gt;Search: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Search"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;input type="submit" name = "Search"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/form&gt;
&lt;/table&gt;

&lt;?php
if(isset($_POST["submit"])){
include 'dbconfig.php';
include 'New Text Document.js';
$Food = $_POST['Food'];
$Price = $_POST['Price'];
$Supermarket = $_POST['Supermarket'];

mysqli_query($conn,"INSERT INTO costsoffood VALUES('$Food', '$Price', '$Supermarket')");

}
if(isset($_POST["Search"])){
    include 'dbconfig.php';
    $search = $_POST["Search"];
    $query="SELECT * FROM costsoffood WHERE Food LIKE %$search%";
    $result=mysqli_query($conn,"SELECT * FROM costsoffood WHERE Food LIKE '%$search%'");
    if(mysqli_num_rows($result)&gt;0){
        while($row = mysqli_fetch_array($result)){
            echo "&lt;tr&gt;&lt;td&gt;". $row['food']."&lt;/td&gt;&lt;td&gt;". $row['price']."&lt;/td&gt;&lt;td&gt;".$row['supermarket']."&lt;/td&gt;&lt;/tr&gt;";
        }
    echo "&lt;/table&gt;";

    }
    else{
        echo "no results";
    }


}
?&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>dbconfig.php</p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dataone";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
  if ($conn-&gt;connect_error) {
    die("Connection failed: " . $conn-&gt;connect_error);
} 

?&gt; 

</code></pre>
