I have this php script that makes this API call and returns JSON response.
<?php
function display(){
$searchKeywords = $_POST['searchKeywords'];
list($firstname, $lastname) = preg_split("/[\s,]+/", $searchKeywords);
$apikey = '**********************';
$string = file_get_contents('https://completecriminalchecks.com/api/json/?firstname='.$firstname.'&lastname='.$lastname.'&apikey='.$apikey, true);
$json = json_decode($string);
$companies = $json;
$output = '
<table class="table table-bordered table-striped" id="member_table" style="font-size:10px">
<th>Name</th>
<th>ID Numbers</th>
<th>Aliases</th>
<th>Birthdate</th>
<th>Race</th>
<th>Sex</th>
<th>Height</th>
<th>Weight</th>
<th>Hair</th>
<th>eyes</th>
<th>address</th>
<th>Crime</th>
</tr>
';
foreach($companies as $company){
foreach($company as $data){
$output .= "<tr>";
$output .= "<td>".$data->full_name."</td>";
$output .= "<td>".$data->id."</td>";
$output .= "<td>".$data->aka."</td>";
$output .= "<td>".$data->dob."</td>";
$output .= "<td>".$data->race."</td>";
$output .= "<td>".$data->sex."</td>";
$output .= "<td>".$data->height."</td>";
$output .= "<td>".$data->weight."</td>";
$output .= "<td>".$data->hair."</td>";
$output .= "<td>".$data->eyes."</td>";
$output .= "<td>".$data->address."</td>";
$output .= "<td>".$data->crime."</td>";
$output .= "</tr>";
}
}
$output .= "</table>";
echo $output;
}
The code seems to work, but there appears to be null or empty nodes which throws errors. I'm not sure why there are showing, if I simply place the url in the browser, the results do not have blank or empty nodes.
After executing the code here its what I see. picture of html response with errors
Anyone have any ideas? what am I missing?
Here is the JSON
{
"response": {
"status": "SUCCESS",
"calls": "4929"
},
"person": [ {
"id": "MI_SEX_65879",
"full_name": "Lynn Francis Wilkinson",
"dob": "05/14/1953",
"race": "White",
"sex": "M",
"height": "507",
"weight": "210lbs",
"hair": "Brown",
"eyes": "Blue",
"address": "714 Howard St Bay City MI 48708",
"crime": "750 520c1a Criminal Sexual Conduct Second Degree Person Under Thirteen ",
"personal": "Lynn Wilkinson ",
"image": "https://datadoesit.com/SOR-Images/MI/5011822-2018864.jpg",
"state": "MI",
"state_name": "Michigan",
"db": "SEX"
} ],
"totals": {
"count": "1",
"sor_count": "1",
"doc_count": "0",
"court_count": "0"
}
}