I have a Json result like this :
Array (
[0] => Array (
[Street] => Street_name
[status] => Best_Shop
[Shop] => Array ( [0] => Array (
[Name] => Bakery_Shop
[Owner] => John
[Type] => 0
[Food] => Cake
[Drink] => Coffee
[Best_Customer] => All
[a] => Good
[b] => Normal
[c] => Bad
[1] => Array (
[Name] => Junk_Foodshop
[Owner] => Mike
[Type] => 0
[Food] => Burger
[Drink] => Coke
[Best_Customer] => All
[a] => Good
[b] => Normal
[c] => Bad )
[Rate] => Average
[Signature] => Boss ) )
And i am trying to create a shop table with rows displaying each stat like this :
Name Owner Type Food Drink Best_Customer a b c
Bakery_Shop John 0 Cake Coffee All Good Normal Bad
Junk_Foodshop Mike 0 Burger Coke All Good Normal Bad
I currently have this code written up and although i am getting the data its not quite working the way i want it to be.
****From json_shop.php****
function getAstCard(){
$json = array();
$json[0] = array(
"Street" => "Street_name ",
"status" => "Best_Shop ",
"Shop" => $Shop,
"Rate" => "Average ",
"Signature" => $conf->get_IXAstUser()
);
return $json;
}
**Into jsonTable.php**
<?php
include 'json_shop.php';
$AstCardTable.='<table style="width:990px;" id="shopcard">';
$AstCardTable.='<thead>';
$AstCardTable.='<tr>';
$AstCardTable.='
<th>Name</th>
<th>Owner</th>
<th>Type</th>
<th>Food</th>
<th>Drink</th>
<th>Best_Customer</th>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>';
$AstCard = getAstCard();
if (count($AstCard) > 0) {
for ($i = 0; $i < count($AstCard); $i++) {
$AstCardRecord = $AstCard[$i];
$AstCardTable.='<tr>';
$AstCardTable.='<td>' . $AstCardRecord['Name'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['Owner'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['Type'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['Food'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['Drink'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['Best_Customer'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['a'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['b'] . '</td>';
$AstCardTable.='<td>' . $AstCardRecord['c'] . '</td>';
$AstCardTable.='</tr>';
}
} else {
$AstCardTable.='<tr>';
$AstCardTable.='<td style="font-family: Verdana;font-weight: bold;font-size: 12px;" colspan=9>Temporarily no data in the list</td>';
$AstCardTable.='</tr>';
}
$AstCardTable.='</tbody>';
$AstCardTable.='</table>';
echo $AstCardTable;
?>
Does anyone with experience in this topic and see if any problem about my code? Any help would be greatly appreciated.Thank you .
return $json[0]['Shop'];fromgetAstCardmethod.