【发布时间】:2018-11-21 15:11:04
【问题描述】:
我正在尝试将包含其值的数组从第一页发送到第二页。在第二页上,我想要发生的是发送的数组值将被传输到一个新数组。 这是我目前的进度:
Report_Status.php的片段代码(首页/来源,其中 具有值的数组已初始化)
$message = array(
'title' => 'Report Approved!',
'body' => 'Thank you for reporting! We already approved/verified your report as a legit fire incident. Wait for the firefighters to arrive.'
);
while ($User_Row = mysqli_fetch_array($Retrieve_User, MYSQLI_ASSOC)){
$User_Token[] = $User_Row['User_Token'];
}
send_notification($User_Token, $message); //calling a function of the second page.
//I will replace the it from calling a function to redirecting to a specific web link
第一页从数据库中检索特定数据(即用户的令牌)并将其存储到数组中 (
$User_Token[])。初始化。
Push_User_Notification.php的片段代码(第二页/目的地,将接收包含其值的数组。
//Here: there should be the code for catching/receving the array
$Retrieve_Target_Tokens_Query = "SELECT * FROM User WHERE User_Token = $tokens";
$Retrieve_Target_Tokens = mysqli_query($Connection, $Retrieve_Target_Tokens_Query);
$tokens = array();
if(!$Retrieve_Target_Tokens){
echo "<script type = 'text/javascript'> alert('Server Error: Could retrieve tokens from database because of this error: ". mysqli_error($Connection)."') </script>";
}
if(mysqli_num_rows($Retrieve_Target_Tokens) > 0){
while($Token = mysqli_fetch_array($Retrieve_Target_Tokens)){
$tokens[] = $Token['User_Token'];
}
}
$message = array("message" => "Your Report has been approved by an admin! Please wait for firefighter/s to arrive.");
send_notification($tokens, $message);
function send_notification ($tokens, $message)
{
//Process of Firebase sending notification here (No problem on this function)
}
问题:
- 如何从一个页面发送数组并成功接收到另一个页面?
附:此代码仅向特定的 android 用户发送推送通知。
【问题讨论】: