I have json data which looks as follows:
{
"firmware": [
{
"Request": "/Firmware/samsung",
"Count": "2954"
},
{
"Request": "/Firmware/apple",
"Count": "2954"
}
],
"exe": [
{
"Request": "/applications/appstore.exe",
"Count": "4482"
}
]
}
I am trying to read it via PHP script and display it. But not seeing any data. The script is as follows:
<script type="text/javascript" src="http://localhost/json/softwarelogs.js"></script>
<fieldset class="light" style="width: 60%; margin-right: 20px; margin-bottom: 20px; float: left;" >
<legend>Top Firmware Downloads</legend>
<div class="statlist" id="topFirmware"> </div>
</fieldset>
<fieldset class="light" style="width: 60%; margin-right: 20px; margin-bottom: 20px; float: left;">
<legend>Top EXE Downloads</legend>
<div class="statlist" id="exe"> </div>
</fieldset>
<script>
var htmlString = "<ol>";
$.each(firmware, function(i, item) {
htmlString = htmlString + "<li>" + item.Request;
});
$('#topFirmware').html(htmlString + "</ol>");
htmlString = "<ol>";
$.each(exe, function(i, item) {
htmlString = htmlString + "<li>" + item.Request;
});
$('#exe').html(htmlString + "</ol>");
$.fn.digits = function(){
return this.each(function(){
$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") );
})
</script>
I am fairly new to PHP programming so not sure about the arrangement and syntax. Please correct me and guide me if something is wrong and if you need more information. Thanks in advance!!