Cita:
Iniciado por rodocoyote15
Código PHP:
Ver original
// acá tu código firebase, usando $res como variable contenedora de los datos.
}
algo asi?:
Cita: //Checking post request
if($_SERVER['REQUEST_METHOD']=='POST'){
//Connection to database
$con = mysqli_connect('localhost','root','','pushnotifica tion');
//Importing firebase libraries
require_once 'firebaseInterface.php';
require_once 'firebaseLib.php';
require_once 'firebaseStub.php';
//Geting email and message from the request
$msg = $_POST['message'];
//Getting the firebase id of the person selected to send notification
$sql = "SELECT * FROM register";
$query = mysqli_query($con,$sql);
while($res = mysqli_fetch_array($query) {
$uniqueid = $res['firebaseid'];
//creating a firebase variable
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL,'');
//changing the msg of the selected person on firebase with the message we want to send
$firebase->set($uniqueid.'/msg', $msg);
}
//redirecting back to the sendnotification page
header('Location: sendPushNotification.php?success');
}else{
header('Location: sendPushNotification.php');
}
PROBE otra cosa:
//Importing firebase libraries
require_once 'firebaseInterface.php';
require_once 'firebaseLib.php';
require_once 'firebaseStub.php';
//Geting email and message from the request
$msg = $_POST['message'];
$result = mysql_query("SELECT COUNT(*) FROM register;");
$contador = 1;
for ($x = 0; $x <= '$result'; $x++) {
$sql = "SELECT * FROM register LIMIT 0,1;"
//Getting the result from database
$res = mysqli_fetch_array(mysqli_query($con,$sql));
//getting the unique id from the result
$uniqueid = $res['firebaseid'];
//creating a firebase variable
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL,'');
//changing the msg of the selected person on firebase with the message we want to send
$firebase->set($uniqueid.'/msg', $msg);
}
//redirecting back to the sendnotification page
header('Location: sendPushNotification.php?success');
}else{
header('Location: sendPushNotification.php');
}
podria añadirle al 0,1 +1 cada vez que va recorriendo el for?...osea 0+1,1+1...?