I have json file like this
[{
"Shop_name": "916",
"Shop_id": "916TCR",
"Address":"cdsasffafa"
"numbers": "4",
"mob_no": "9447722856"
}, {
"Shop_name": "Chicking",
"Shop_id": "CKGTCR",
"Address":"afagagg",
"numbers": "8",
"mob_no": "6767564532"
}]
i want to see this as HTML Table with row head as Shop_name,Shop_id,Address and Data in next row.
i tried decoding it and display as table (How can i parse json into a html table using PHP?). but Json File format is diffrent here. Also like to know if Json File gets bigger with [0],[1],[2]....
You should parse your json data to php object than you should iterate your data like below;
$myData = <<<JSON
[
{"Shop_name":"minh",
"Shop_id":"916TCR",
"Address":"cdsasffafa",
"numbers":"4",
"mob_no":"9447722856"
},
{"Shop_name":"Chig",
"Shop_id":"CKGTCR",
"Address":"afagagg",
"numbers":"8",
"mob_no":"6767564532"
}
]
JSON;
$myObject = json_decode($myData);
?>
<table>
<tr>
<td>Shop Name</td>
<td>Shop ID</td>
<td>Address</td>
<td>Numbers</td>
<td>Mob No</td>
</tr>
<?PHP
foreach($myObject as $key=>$item)
{
?>
<tr>
<td><?PHP echo $item->Shop_name; ?></td>
<td><?PHP echo $item->Shop_id; ?></td>
<td><?PHP echo $item->Address; ?></td>
<td><?PHP echo $item->numbers; ?></td>
<td><?PHP echo $item->mob_no; ?></td>
</tr>
<?PHP
}
?>
</table>
A working example is here: http://ideone.com/IqZLMs
PS: You should fix this ” quote to "