How to connect MySQL db using new XAMPP
<p>Old connection method <code>mysql_connect</code> maybe deprecated from PHP7 so what is the best way to connect and query in mysql using XAMPP or how I implement PDO in my bellow script.</p>

<pre><code>&lt;?php
    $key = $_GET['key'];
    $array = array();
    $con = mysql_connect("localhost", "root", "");
    $db = mysql_select_db("search", $con);

    $query = mysql_query("select * from ajax_example where name LIKE '%{$key}%'");

    while ($row = mysql_fetch_assoc($query)) {
        $array[] = $row['name'];
    }
    echo json_encode($array);
?&gt;
</code></pre>