Hello i am trying to user Autocomplete jqueryUI but i having trouble showing data from my database. I pretty sure that the problem lies there. Here is the code
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'project');
$db = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD,DB_DATABASE) or die(mysqli_connect_error());
mysqli_query ($db,"set character_set_results='utf8'");
// if the 'term' variable is not sent with the request, exit
if(isset($_REQUEST['select3']))
{
// query the database table for zip codes that match 'term'
$rs = mysqli_query('SELECT uid, username FROM users WHERE username LIKE "'. mysqli_real_escape_string($_REQUEST['term']) .'%" ORDER BY username ASC LIMIT 0,10', $db);
// loop through each zipcode returned and format the response for jQuery
if ( $rs && mysqli_num_rows($rs) )
{
while( $row = mysqli_fetch_array($rs, MYSQL_ASSOC) )
{
$row['uid'] .', '. $row['username'];
}
}
}
// jQuery wants JSON data
echo json_encode($data);
flush();
?>
and here is when i call it
<form action="test/submit.php" method="POST" accept-charset="utf-8">
<select id="select3" name="select3">
<option value="sleep" class="selected">sleep</option>
<option value="sport">sport</option>
<option value="freestyle">freestyle</option>
</select>
<br/>
<br/>
<input type="submit" value="Send">
</form>
<script type="text/javascript">
$(document).ready(function(){
$("#select3").fcbkcomplete({
json_url: "ajax_autocomplete.php",
addontab: true,
maxitems: 10,
input_min_size: 0,
height: 10,
cache: true,
newel: true,
select_all_text: "select",
});
});
</script>
Can you see an error?
Sorry but i cant make any donations because of the capital controls in Greece. :(