Greetings.
I'm trying out the script.acul.ous Ajax.Autocompleter and I am not getting any results.
test.php:
PHP Code:
<html>
<head>
<link type="text/css" rel="stylesheet" href="resources/styles/style_index.css">
<script src="resources/js/prototype.js" type="text/javascript"></script>
<script src="resources/js/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
var myAutoCompleter = new Ajax.Autocompleter('username', 'suggestionBox', 'suggest_username.php', {minChars: 0, frequency: 0.1});
</script>
<style>
.selected {
background-color: #ffffef;
}
#suggestionBox {
display: none;
border: 1px solid #888888;
background-color: #efefff;
width: 200px;
}
</style>
</head>
<body>
<input type="text" name="username" id='username'>
<div id="suggestionBox"></div>
</body>
</html>
suggest_username.php
PHP Code:
<?php
require_once "include/connection.php";
$link = openDB();
$str = $_POST['username'];
$result = mysql_query("SELECT * FROM users WHERE username LIKE '$str%'", $link) or die(mysql_error());
$count = mysql_num_rows($result);
echo "<ul>";
if($count > 0) {
while($data = mysql_fetch_array($result)) {
echo "<li>" . $data['username'] . "</li>";
}
} else {
echo "<li>No results.</li>";
}
echo "</ul>";
?>
What am I doing wrong? Please help me.
Best Regards,
zEeLi
Bookmarks