I have two "tables" that are USER and CONGE. In the table "CONGE" I inserted the id of the users. However I do not know how to display the user's leave according to their id.
I would like to post the "Congé" according to id.
{
"conge" : {
"-LaW8hzv8O3PSlZk6OPIJU" : {
"Mouth" : "January",
"id_user" : "LaW_9iIrm_-tiDpWEE7"
}
},
"user" : {
"-LaW_9iIrm_-tiDpWEE7" : {
"email" : "asdfasdf",
"name" : "Michel",
"prenom" : "adadfas"
},
"-LaWfQpaRfludVkzAPvq" : {
"email" : "dup@gmail",
"name" : "Michel",
"prenom" : "dupuis"
},
"-LaWfTTF-Lifs79bGbhy" : {
"email" : "JC@gmail",
"name" : "Jean ",
"prenom" : "Louzis"
}
}
}
`
var rootRef = firebase.database().ref().child("user");
rootRef.on("child_added",function(snap){
var name = snap.child("name").val();
var email = snap.child("email").val();
var prenom = snap.child("prenom").val();
$("#table_body").append("<tr><td>"+name+"</td><td>"+prenom+"</td><td>"+email+"</td></tr>");
// $("#table_body").append("<tr><td>"+name+"</td><td>"+email+"</td><td><button id='rem' onclick='remove()'>Remove</button></td></tr>");
});
function remove(){
// console.log(firebase.database().ref().child('user').push().key);
rootRef.remove();
location.reload();
}
function add(){
console.log(name);
alert("COOL");
}`