2017-08-17 87 views
0

在火力最新的用戶數據從下面這個圖片:如何獲得使用JavaScript和HTML

我怎樣才能得到userResult的兒童從最近的用戶(示例用戶rricarde)? 從這個圖像下面我需要獲得最新的用戶數據,並且它的所有最新的答案,並追加到HTML表格數據類=「專家迴應」

enter image description here

輸出示例: 數據從最近的用戶得到:如果您在使用火力鍵rricarde

<table id="results"> 
    <tr> 
    <th>Expert response</th> 
    </tr> 
    <tr> 
    <td><span class="expert-response"> Somewhat agree</span></td> 
<!--Statement01 most recent answer --> 
    <td><span class="expert-response">Yes, usually</span></td> 
<!--Statement02 most recent answer --> 
    </tr> 
</table> 

回答

0

,所有的火力鍵與在它的時間戳生成的,所以它已經預先排序,最後一個將是最後的輸入,但是如果你想知道如何如此rt in firebase。

firebase.database().ref(endpoint) 
 
    .orderByChild('timestamp') 
 
    .on('value', function(snapshot){ 
 
    //do something here 
 
    })

orderbychild

還有更多可以做,你可以閱讀的API。
對於你的第二個問題,我認爲你應該多學習一下如何在html中呈現Firebase內容。