I have two related tables "Friends" and "Messages" I make a query that throws all the ids of my friends and then send that result via ajax and make a evaluation with that result with an "if", in fact I have no problem, I throw the expected result, the problem is that I do not know how to make that result. I explain myself with coigo for better understanding
session_start();
include="conexion.php";
//esta es la consulta y el resultado es exitoso
$query=mysqli_query($conexion,"SELECT * FROM
amigos RIGHT JOIN
mensajes ON amigos.para = mensajes.id_user ");
while($row=mysqli_fetch_array($query)){
echo json_encode(array("usuarios"=>$row["id_user"]));
}
//este es el resultado de mi consulta me esta arrojando justamente los ids que esperaba
{"usuarios":26}, {"usuarios":6}, {"usuarios":8}, {"usuarios":19}
Well, let me explain, that result I send with the json_encode for back and in the js file when I recive that data what I would like to do the following:
//ejemplo en el success
success:function(data){
console.log(data)//por la consola puedo ver el resultado
//un ejemplo muy simple para que se pueda entender
if (data["usuarios"]==26 || data["usuarios"]==13){
alert("numero de usuario no autoridado");
}
}
As you can see the code is very simple and understandable I think, now I do not do anything with that code or show me an error or something, it is obvious that something is wrong or I'm not doing something right I would appreciate any help thanks