jQuery Success or Fail response help needed.
Hi,
I have an html page that send out a jQuery post to a php PDO page to query the db with a select statement. The result gets sent back to the HTML page as json_encode....
The result may return an empty result with no records.
I can check for this using count...
if (count($records) > 0) {
$output = [];
foreach ($records as $key=>$record) {
$output[$key]["First"] = $record['First'];
$output[$key]["Last"] = $record['Last'];
//etc.
}else{
$output = [];
//????? How do I create a proper $output[$??] ??? response to send back a failed - empty result to the HTML PAGE?
}
print_r (json_encode($output));
Thanks in advance - Dave
