How can I display the present data instead of getting multiple data.
I want to remove the previous data because whenever new data is stored on Firebase it copies the same data about 4 times.
I'm using a mobile app to send data to Firebase. I've changed databaseref.once to databaseref.on so it can be a real-time database however multiple data is stored on my table.
<html> <head> <title>Firebase Realtime Database Web</title> <script> // firebase config here </script> </head> <body> <h3>Police Station 1</h3> <table id="reports" border="1"> <tr> <th>Email Address</th> <th>Caption</th> <th>Location</th> <th>Time</th> <th>Picture</th> </tr> </table> <script> var tblUsers = document.getElementById('reports'); var databaseRef = firebase.database().ref('PP3/'); var rowIndex = 1; databaseRef.on('value', function(snapshot) { snapshot.forEach(function(childSnapshot) { var childKey = childSnapshot.key; var childData = childSnapshot.val(); var row = tblUsers.insertRow(rowIndex); var email = row.insertCell(0); var caption = row.insertCell(1); var location = row.insertCell(2); var time = row.insertCell(3); var picture = row.insertCell(4); email.appendChild(document.createTextNode(childData.Email.replace(/\\/g, '').replace(/"/g, ''))); caption.appendChild(document.createTextNode(childData.Caption.replace(/\\/g, '').replace(/"/g, ''))); location.appendChild(document.createTextNode(childData.Location.replace(/\\/g, '').replace(/"/g, ''))); time.appendChild(document.createTextNode(childData.Time.replace(/\\/g, '').replace(/"/g, ''))); picture.appendChild(document.createTextNode(childData.Picture.replace(/\\/g, '').replace(/"/g, ''))); rowIndex = rowIndex + 1; }); }); </script> </body> </html>