masnobi Posted April 15, 2013 Share Posted April 15, 2013 Hi all, I am making a flight search engine where i am trying to create a autocomplete textbox. I mean when a user starts typing in the textbox, it will show all related data from my database table. I am new to programming and therefore I have adopt a code from online but it doesn't work, I don't know why. Can anyone please help? If you know any other easy way of doing it, please tell me also This is my Javascript code: <script type="text/javascript" src="js/jquery-1.4.2.js"></script> <script type='text/javascript' src="js/jquery.autocomplete.js"></script> <script type="text/javascript"> $().ready(function() { $("#depAirport").autocomplete("autoCompleteMain.php", { width: 260, matchContains: true, //mustMatch: true, //minChars: 0, //multiple: true, //highlight: false, //multipleSeparator: ",", selectFirst: false }); }); </script> This is my html: <form> <label for="depAirport">Deperture airport</label> <input type="text" id="depAirport" name="depAirport" placeholder="Type destination airport" required autofocus> </form> and this is my php: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="root"; // Mysql password $db_name="airline_database"; // Database name $con = mysql_connect($host,$username,$password) or die(mysql_error()); mysql_select_db($db_name, $con) or die(mysql_error()); $q = strtolower($_GET["q"]); if (!$q) return; $sql = "select DISTINCT departure_airport as departure_airport from depAirport where departure_airport LIKE '%$q%'"; $rsd = mysql_query($sql); while($rs = mysql_fetch_array($rsd)) { $cname = $rs['departure_airport']; echo "$cname\n"; } ?> PLEASE HELP ASAP Quote Link to comment https://forums.phpfreaks.com/topic/276957-help-needed-for-autocomplete-textbox/ Share on other sites More sharing options...
jugesh Posted April 23, 2013 Share Posted April 23, 2013 check for connection variables.. It seems they are wrong Quote Link to comment https://forums.phpfreaks.com/topic/276957-help-needed-for-autocomplete-textbox/#findComment-1426057 Share on other sites More sharing options...
jugesh Posted April 23, 2013 Share Posted April 23, 2013 instead of name (output) try to print query and run it in phpmyadmin interface you will come to know if there is any error Quote Link to comment https://forums.phpfreaks.com/topic/276957-help-needed-for-autocomplete-textbox/#findComment-1426058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.