This topic is locked
[SOLVED]

passing array from Server to Client After

7/15/2022 11:27:49 AM
PHPRunner General questions
P
ppradhan@live.com author
P
ppradhan@live.com author 7/15/2022

how can I pass data (array) from Server to Client After, and how to retrieve those array values in the client after? please help me.

purpose:
Custom Button
Client Before = will show a dialog API box and ask for userid that will be passed to server event
Server Event: will query database and gets array of data and this needs to pass to client after event.
Client After: This needs to show dialog or swal message with the list of array (table) data to the user as final output.

M
macalister 7/16/2022

Hello.

Yo need store the the data into array and pass it to the client after.

Server Event Button:

$info = array();

$sql = DB::PrepareSQL("select fields from table where condition like ':1'", $user_input_data);
$rs = DB::Query($query);
while($data = $rs->fetchAssoc()){
$info[] = $data['field'];
}
$result['info'] = implode('< br >', $info); // remove spaces of br tag

Client After (show info):

var info = result['info'];
var icon = "success";
var html_message = document.createElement("div");
html_message.innerHTML = info;

swal({
title: "Your title",
content: html_message,
icon: icon
});
P
ppradhan@live.com author 7/17/2022

@macalister7, thank you so much. Works with charm.