I am trying to get remote autocomplete array
$items = array(
"PR-1001"=>"Product 1",
"PR-1002"=>"Product 2"
);
Input autocomplete suggection will be PR-1001 and PR-1002 and div will be appended with Product 0 or Product 2 depending on selection of autocomplete. I tried using following code but can't Please help me to get array as mentioned above.
$query = "SELECT * FROM products";
$results = mysql_query($query, $connection);
confirm_query($results);
$count = mysql_num_rows($results);
while($row = mysql_fetch_array($results)) {
$codes =array("{$row['pr_code']}");
$names =array("{$row['pr_name']}");
$i = 0;
$items[$i] = "\"" . $codes[$i] ."\"=>\"" . $names[$i] ."\", ";
$items = implode(", ", $items);
$i++;
}
I need a php array that show print_r
Array ( [DJ-1001] => Product 1 [DJ-1002] => Product 2 )
Thank you in advance.
Here's answer
$items = array();
while($row = mysql_fetch_array($results)) {
$items[$row['pr_code']] = $row['pr_name'];
}
Thank you friends!