how can i get userid from my mysql database and implement it in the code. I can't use regular PHP variable.
$device_id = mysqli_query($conn,"SELECT notification_id FROM app WHERE customer_id='$form_customer_id' AND status='ACTIVE'");
if(mysqli_num_rows($device_id) >= 1)
{
while($row = mysqli_fetch_array($device_id))
{
$onesignal_id=$row['notification_id'];
}}
and here is a code
$content = array(
"en" => 'TEST PUSH MES'
);
$hashes_array = array();
array_push($hashes_array, array(
"id" => "like-button",
"text" => "Like",
"icon" => "xxx",
"url" => "xxx"
));
array_push($hashes_array, array(
"id" => "like-button-2",
"text" => "xxx",
"icon" => "xxx",
"url" => "xxx"
));
$fields = array(
'app_id' => "xxx",
'include_player_ids' => array(
'HERE I HAVE PROBLEM. I need to get the user id at this point from my MYSQL DATABASE'
),
'data' => array(
"foo" => "bar"
),
'contents' => $content,
'web_buttons' => $hashes_array
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Authorization: Basic xxxxxxx'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode($return);
$data = json_decode($response, true);
print_r($data);
$id = $data['id'];
print_r($id);
print("\n\nJSON received:\n");
print($return);
print("\n");
I need to get the user ID from the database and put it in the script. Unfortunately, I am learning and I don't really know how to interfere with the code. I thought I could put a variable there, unfortunately it doesn't work
Thx for help! :)