我正在尝试将具有其值的数组从第一页发送到第二页。在第二页上,我想发生的是它已发送的数组值将被传输到新数组。 这是我当前的进度:
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)
}
问题:
P.S。这段代码仅向特定的android用户发送推送通知。
答案 0 :(得分:1)
我会为此使用会话。
以下是您需要答案的类似问题:Pass array from one page to another
答案 1 :(得分:1)
您可以使用Session变量链接:http://php.net/manual/en/reserved.variables.session.php
,或者如果要通过Java调用调用,则可以使用JSON传递。
希望这很有帮助:)