Auto suggest text box using PHP and jQuery

pedoontoste

New Member
I am trying to do an auto suggest text box using PHP and jQuery however, all the jQuery I am using, basing on the internet has already deprecated. I am not sure if my code is the one not working or the jQuery. Could anyone help me please? :) Thank you in advance!\[code\]session_start();?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>jQuery Autocomplete Plugin</title><script type="text/javascript" src="http://stackoverflow.com/questions/15717593/js/jquery-1.4.2.js"></script><script type='text/javascript' src="http://stackoverflow.com/questions/15717593/js/jquery.autocomplete.js"></script><link rel="stylesheet" type="text/css" href="http://stackoverflow.com/questions/15717593/js/jquery.autocomplete.css" /><script type="text/javascript">$().ready(function() {$("#users").autocomplete("autoCompleteMain.php", {width: 260,matchContains: true,selectFirst: false});});</script></head><body><h2 id="banner">Autocomplete</h1><div id="content"><form autocomplete="off"><p>Enter Username <label>:</label><input type="text" name="users" id="users" /></p><input type="submit" value="http://stackoverflow.com/questions/15717593/Submit" /></form></div></body></html>\[/code\]\[code\]<?php$host="localhost"; // Host name$username="root"; // Mysql username$password="aaaa"; // Mysql password$db_name="maptemp"; // 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 username from users where username LIKE '%$q%'";$rsd = mysql_query($sql);while($row = mysql_fetch_array($rsd)) {$cname[] = $row['username'];}echo json_encode($cname);?>\[/code\]
 
Back
Top