HELP ! Getting values from database

Karolis's Avatar


29 Jan, 2013 09:56 AM

What am I doing wrong? chrome consol does not show any error.

plugin works only with
var data = {items: [ {value: "21", name: "Mick Jagger"}, {value: "43", name: "Johnny Storm"}, {value: "46", name: "Richard Hatch"}, {value: "54", name: "Kelly Slater"}, {value: "55", name: "Rudy Hamilton"}, {value: "79", name: "Michael Jordan"} ]}; $("input[type=text]").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"}); <head> <script src="<?php echo base_url(); ?>js/libs/jquery-ui-1.8.16.min.js"></script> <script defer src="<?php echo base_url(); ?>test/jquery.autoSuggest.js"></script> <link rel="stylesheet" href="<?php echo base_url(); ?>test/autoSuggest.css"> </head> .....................................
<input type="text" name="q" id="q"/> <script> $(document).ready(function() { $("#q").autoSuggest("<?php echo base_url(); ?>test/auto.php", {minChars: 2, matchCase: true}); }); </script>

auto.php file
<? $input = $_GET["q"]; $data = array(); // query your DataBase here looking for a match to $input $query = mysql_query("SELECT * FROM minimi_asmenys WHERE asmuo LIKE '%$input%'"); while ($row = mysql_fetch_assoc($query)) { $json = array(); $json['value'] = $row['asmens_id']; $json['name'] = $row['asmuo']; $data[] = $json; } echo json_encode($data); ?>

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac