I am using an API to return json that I will use in my application to display data in a html table:
$response = $api->listusers();
$data = json_decode($response, true);
echo '<table>';
foreach($data as $result){
//print_r($result);
echo '<tr>';
echo '<td>'.$result->name.'</td>';
echo '<td>'.$result->id_user.'</td>';
echo '<td>'.$result->backup.'</td>';
echo '<td>'.$result->status.'</td>';
echo '</tr>';
}
echo '</table>';
However when I try to Loop Through it I get a blank page the only code that works is if I try to display variables with print_r
and the result is an array:
OKArray (
[0] => Array ( [name] => James [id_user] => 3 [backup] => on [status] => active )
[1] => Array ( [name] => James [id_user] => 3 [backup] => on [status] => active )
)
How can I create a html table from this data?