Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/05/2016, 10:20
MrEnfurecido
 
Fecha de Ingreso: abril-2016
Mensajes: 15
Antigüedad: 8 años, 8 meses
Puntos: 0
Respuesta: Enviar a multiples usuarios a la vez

Cita:
Iniciado por rodocoyote15 Ver Mensaje
Código PHP:
Ver original
  1. $query = mysqli_query($con,$sql);
  2.  
  3. while($res = mysqli_fetch_array($query) {
  4.    // acá tu código firebase, usando $res como variable contenedora de los datos.
  5. }
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...?

Última edición por MrEnfurecido; 24/05/2016 a las 11:23