/    Sign up×
Community /Pin to ProfileBookmark

prepare multidimensional array from PHP using jQuery autocomplete

extending my previous post, link below:
https://www.webdeveloper.com/d/390686-multiple-columns-in-one-input-field-using-jquery-autocomplete

[code]
if ($request == 2) {
$id = $_POST[‘id’];
$sql = “SELECT * FROM MY_COMPONENTLIST WHERE id=”.$id;
$result = mysqli_query($con, $sql);
$AncillaryPricing_arr = array();
while ($row = mysqli_fetch_array($result)) {
$id = $row[‘id’];
$codeANCILLARY = $row[‘matDes1’];
$mat50ANCILLARY = $row[‘matCost1’];
**//***************************
//***************************
$codeANCILLARY = $row[‘matDes2’];
$mat50ANCILLARY = $row[‘matCost2’];
.and
.so on
.until 5
//***************************
//*****************************
$unitsANCILLARY = $row[‘units’];
$AncillaryPricing_arr[] = array(
“id” => $id,
“codeANCILLARY” => $codeANCILLARY,
“mat50ANCILLARY” => $mat50ANCILLARY,
“unitsANCILLARY” => $unitsANCILLARY
);
}
echo json_encode($AncillaryPricing_arr);
exit;
}
[/code]

dear members i think my problems lying here as shown above, when trying to set up a jQuery autocomplete that uses results from a PHP MySql query.

please help or advise , how can i achieve this .

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 24.2020 — Replaced the back-ticks in the original post with ... tags.
Copy linkTweet thisAlerts:
@NogDogJul 24.2020 — @sam777#1621230

So, what is the expected result versus the actual result?
Copy linkTweet thisAlerts:
@sam777authorJul 24.2020 — @NogDog#1621251

i really dont know anymore

what i know for sure .. im stuck ☹️
Copy linkTweet thisAlerts:
@sam777authorJul 24.2020 — I have a dynamic table with add and remove rows inside my HTML file.

Inside this table I have textarea and input, whenever I start typing will show me suggestions, and if I select one, will automatically populate other fields.

Here below my textarea and input:
<i>
</i>&lt;textarea id='codeANCILLARY_1' class='codeANCILLARY' name="codeANCILLARY[]"&gt;&lt;/textarea&gt;

&lt;input type="text" id="mat50ANCILLARY_1" class="mat50ANCILLARY" name="mat50ANCILLARY[]" /&gt;

textarea Searching through matDes1 to matDes5. so no problem here.

the problem is when selecting to populate both field, only accepting matDes1 and matCost1 not the rest.

is there a way to use say something like if statement or any and say:
<i>
</i>if (matDes1 selected) {
show matDes1 with matCost1
} else if (matDes2 selected){
show matDes2 with matCost2
}
and
so
on


for days now cant do anything else. is like my brain stopped working :sad
×

Success!

Help @sam777 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...