Marine1969
IS-IT--Management
I finally got my ajax working but not quite getting the desired result. Below is the search page. There are 3 questions here...
1. The ajax results make the textbox wider that the screen. So rather than creating 1 result per line it keeps going until it runs out of room and then then returns. So I can have 10+ results per line, although it does highlight each result when hovering. How do I get them to return 1 per line?
2. Is there a way to get the textbox to have a different value like a select box where you can display a name but the option value is an id?
3. Is there a way to adjust the execute line to also include the producer? IE. "if producer Like %$_GET['term']% or name Like %$_GET['term']% "
1. The ajax results make the textbox wider that the screen. So rather than creating 1 result per line it keeps going until it runs out of room and then then returns. So I can have 10+ results per line, although it does highlight each result when hovering. How do I get them to return 1 per line?
2. Is there a way to get the textbox to have a different value like a select box where you can display a name but the option value is an id?
3. Is there a way to adjust the execute line to also include the producer? IE. "if producer Like %$_GET['term']% or name Like %$_GET['term']% "
PHP:
$str = $conn->prepare("Select clientvendors.producer, products.name "
. "From products Inner Join clientvendors On clientvendors.idcv = products.idcv "
. "Where products.idclient=2 and name Like :name Order By clientvendors.producer, products.name");
$str->execute([':name' => "%{$_GET['term']}%"]);
$select = $str->fetchAll();
foreach ($select as $row) {
$data[] = $row['producer'] . ": " . $row['name'];
//$data[] = $row['name'];
}
//return json data
header('Content-Type: application/json');
echo json_encode($data);