Hello.I previously made a post and it led me to this point but I seem to be getting no where. It may be a problem of where I’m aiming in the database. Thank you in advance.
Hello!
</head>
<body>
<script src="jquery-3.3.1.min.js"></script>
<table id ="orders" style ="width:50%">
<tr>
<th>Order</th>
<th>name</th>
<th>order No.</th>
<th>Items</th>
<th>Price</th>
</tr>
</table>
</body>
</html>
<style>
body {
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
margin: 2em;
}
h1 {
font-style: italic;
color: #373fff;
}
#orders{
border:2px solid black;
}
th{
border: 1px solid black;
border-left:none;
border-right:none;
}
</style>
<script>
var config = {
apiKey: "*****",
authDomain: "mycanteenapp-b0dfc.firebaseapp.com",
databaseURL: "https://mycanteenapp-b0dfc.firebaseio.com",
projectId: "mycanteenapp-b0dfc",
storageBucket: "mycanteenapp-b0dfc.appspot.com",
messagingSenderId: "18960278720"
};
firebase.initializeApp(config);
console.log("hello")
var database = firebase.database(MyCanteen);
database.ref(break).once('value', function(snapshot){
console.log("hello")
if(snapshot.exists()){
var content = '';
snapshot.forEach(function(data){
var val = data.val();
content +='<tr>';
content += '<td>' + val.Order + '</td>';
content += '<td>' + val.name + '</td>';
content += '<td>' + val.orderNo + '</td>';
content += '<td>' + val.Items + '</td>';
content += '<td>' + val.Price + '</td>';
content += '</tr>';
});
$('#orders').append(content);
}
});
/*var messagesRef = new Firebase('https://mycanteenapp-b0dfc.firebaseio.com"');
messagesRef.limitToLast(10).on('child_added', function (snapshot) {
var data = snapshot.val();
var message = data.text;
if (message != undefined)
{
messageResults.value += '\n' + message;
}
});*/
</script>
MOD EDIT: remove sensitive data