how to search sql database using php
<p>For the past couple days, I have been trying to learn how to search an mysql database. So far I have the code below. for some reason it isn't searching and giving me results back. my database is named score and the table is all scores. Someone please help me with this.</p>
<p>It should be searching my database but it's coming up with no results. I have made sure everything is correct.</p>
<p>This file is searching.php</p>
<pre><code>&lt;?php

if (isset($_POST['search'])) {
    $id = $_POST['id'];
    $connect = mysqli_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;root&quot;, &quot;score&quot;);
    $query = &quot;SELECT `name` FROM `all_scores` WHERE `id` = $id LIMIT 1&quot;;
    $result = mysqli_query($connect, $query);

    if (mysqli_num_rows($result) &gt; 0) {
        while ($row = mysqli_fetch_array($result)) {
            $name = $row['name'];
        }
    } else {
        echo &quot;Undifined ID&quot;;
        $gameid = &quot;&quot;;
    }

    mysqli_free_result($result);
    mysqli_close($connect);
} else {
    $gameid = &quot;&quot;;
}
</code></pre>
<p>this is search.php</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt; PHP FIND DATA &lt;/title&gt;
    &lt;meta charset=&quot;UTF-8&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form action=&quot;searching.php&quot; method=&quot;post&quot;&gt;
        Id:&lt;input type=&quot;text&quot; name=&quot;id&quot;&gt;&lt;br&gt;&lt;br&gt;
        &lt;input type=&quot;submit&quot; name=&quot;search&quot; value=&quot;Find&quot;&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>