0

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. :(

2
Contributors
4
Replies
10
Views
1 Year
Discussion Span
Last Post by SimonIoa
0

No that wasn't it. It wasnt making any difference anyway. Do you see any other errors?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.