Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //AutoComplete code in question
- $(function() {
- var itemcode_ac = {
- source: "/webservices/whs_bincodeAC.php",
- select: function(event, ui) {
- $('#txtBin').val(ui.item.value);
- getWhsInfo();
- },
- minLength: 1
- }
- $('#txtBin').autocomplete(itemcode_ac);
- });
- <?php
- if(isset($_GET["term"]) && !empty($_GET["term"])) {
- include_once $_SERVER['DOCUMENT_ROOT'].'/path/to/dbConnect.php';
- $term = mysql_real_escape_string(trim($_GET["term"]));
- //wildcard appended here for parameterized query (MySqli)
- $term .= "%";
- $query = "SELECT DISTINCT BinCode, ItemCode, ItemName, WhsCode, DataAsOfDate FROM whse_tbl
- WHERE BinCode LIKE '$term' or ItemCode LIKE '$term' ORDER BY BinCode LIMIT 0, 10";
- $res = mysql_query($query);
- //This is the debug code I described above
- /*if($row = mysql_fetch_assoc($res))
- echo json_encode(array(array('value' => "is row")));
- else
- echo json_encode(array(array('value' => "no row")));
- return;*/
- $matches = array();
- while($row = mysql_fetch_assoc($res))
- {
- $matches[] = array('value' => $row["BinCode"], 'label' => $row["BinCode"].' - '.$row["ItemCode"],
- 'name' => $row["ItemName"], 'whscode' => $row["WhsCode"], 'asOfDate' => $row["DataAsOfDate"]);
- }
- echo json_encode($matches);
- }
- ?>
Add Comment
Please, Sign In to add comment