I'm trying to get data into the tabular format by invoking JSON data into PHP code.
JSON code written to use for converting into tabular format.
[
{
"#":"3586 "
"Project" :"SSMT",
"Tracker" :"Maintenance",
"Status" : "To Do"
"Subject" : "Test the following scenario and provide the relevant scripts in centos7"
"Author" : "Anil K"
"Assignee" : "SSMT Group"
},
{
"#" :"3517"
"Project" : "SSMT"
"Tracker" : "Improvement"
"Status" : "In Progress"
"Subject" : "Image server daily backup"
"Author" : "Lakshmi G"
"Assignee" : "Pooja S"
},
{
"Project" : "SSMT"
"Tracker" : "Improvement"
"Status" : "In Progress"
"Subject" : "setup openstack all-in-one in centos7 instance on ORAVM1 box."
"Author" : "Anil K"
"Assignee" : "Bhanuprakash P"
}
]
The below php code is written to fetch the above JSON data.
<!DOCTYPE html>
<html lang = "en-US">
<?php
$url = 'data.json';
$data = file_get_contents($url);
$characters = json_decode($data);
echo $characters[0]->name;
foreach ($characters as $character) {
echo $character->name . '<br>';
}
?>
<table>
<tbody>
<tr>
<th>#</th>
<th>Project</th>
<th>Tracker</th>
<th>Status</th>
<th>Subject</th>
<th>Author</th>
<th>Assignee</th>
</tr>
<?php
foreach ($characters as $character) {
echo '<tr>'
echo '<td>' . $character-># . '</td>';
echo '<td>' . $character->project . '</td>';
echo '<td>' . $character->tracker . '</td>';
echo '<td>' . $character->status . '</td>';
echo '<td>' . $character->subject . '</td>';
echo '<td>' . $character->author . '</td>';
echo '<td>' . $character->assignee . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</html>
I received following error
PHP Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/html/tabularformat.php on line 34
can anyone suggest othis? ?
after adding ; at the end of each 'echo' statement. also getting the same error. please find it.