简体   繁体   中英

Retrieve data from all users then show their user ID in a html table and update via button

I want to have a table like this

所需表

which will get data from the firebase database, here is my firebase database structure for requests Firebase请求结构 .

Here's my code which I tried to edit from a previous question , but as you can see from the table above the data says undefined.

<table class="table table-striped" id="ex-table">
<thead class="thead-inverse">
    <tr>
    <th>ID Number</th>
    <th>Request Status</th>
    </tr>
</thead>
<tbody>
    <tr id="tr">
    <td id="status"></td>
   </tr>
   </tbody>


<script>

    var database = firebase.database().ref().child('Request');
    database.once('value', function(snapshot){
    if(snapshot.exists()){
    var content = '';
    snapshot.forEach(function(data){
          var status= data.val().status;
        content += '<tr>';
        content += '<td>' + status + '</td>';//column2
        content += '</tr>';
    });

    $('#ex-table').append(content);
    }
});

</script>

This is for my admin panel which approves the requests of the users, also how can I do the approval using 2 buttons named Approve and Deny?

Sorry for the inconvenience I am new to firebase. Thank you very much!

I have used a keyword named status inside my firebase database. I replaced it and then boom it worked like a charm. I am very sorry for wasting your time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM