Using PDO to search database
<p>I am attempting to create a search function for my website using PDO. At the moment I send the search query through the URL and then try to fetch the results however whenever I do a var dump it returns null. I tested the query on PHP my admin and it returns around 4 results. </p>

<p>I use a class I created to connect to the database, this works on all my other queries.</p>

<p>Here is my search function </p>

<pre><code>function search($query) {

    $sql = "SELECT * FROM `Sweets` WHERE `Description` LIKE :search";
    $stmt = $this-&gt;connection-&gt;prepare($sql);
    $stmt-&gt;bindParam(':search', $query);

    $stmt-&gt;execute();

    $done = $stmt-&gt;fetch();

    var_dump($done[0]);


}
</code></pre>

<p>Below is the search php my form calls as an action</p>

<pre><code>&lt;?php
// Start our connecting to our database
require('class-database-functions.php');

$database = new Database_Functions();

// Get the search value passed through $_GET
$search_query = $_GET['query'];

$search = $database-&gt;search($search_query);


?&gt;
</code></pre>