How to Autocomplete Textbox Using jQuery,PHP and MySQL

this tutorial we will show you how to create autocomplete textbox using jQuery, PHP and MySQL.When user enter some letter a box with some related words will display and you can select the word from that box.This is all done with the help of jQuery UI you have to download it to create autocomplete textbox. You may also like Live Search in php with Ajax and Mysql.


        <script src=""></script>
        <link href="" rel="Stylesheet"></link>
        <script src=""></script>    
        <script type="text/javascript">
            $(function ()
                    source: 'autocomplete.php'
        <div id="wrapper">

            <div class="ui-widget">
                <p>Enter Coding Language</p>
                <input type="text" id="coding_language">


PHP Code (autocomplete.php)

define('DB_SERVER', "localhost");
define('DB_USER', "root");
define('DB_PASS', "");
define('DB_DATABASE', "ieltsmedidb");
$con = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);

$searchTerm = $_GET['term'];
$select = mysqli_query($con, "SELECT * FROM medical_student WHERE student_name LIKE '%" . $searchTerm . "%'");
while ($row = mysqli_fetch_assoc($select)) {
    $data[] = $row['student_name'];

echo json_encode($data);

Leave a Reply

Your email address will not be published. Required fields are marked *