function JSON_print($result, $child = false) { $is_child = 0; $AjaxReturn = array(); foreach ($result as $key => $val) { $is_child = 0; if (is_array($val)) { $AjaxReturn[] = JSON_print($val, true); $is_child++; } else { $AjaxReturn[] = '"' . $key . '":"' . $val . '"'; } } $return_json = $is_child > 0 ? '[' . implode(',', $AjaxReturn) . ']' : '{' . implode(',', $AjaxReturn) . '}'; return $return_json; }
$temp['qty'] = $_delivery['qty']; $temp['gross'] = $_delivery['gross']; $temp['core'] = $_delivery['core']; $temp['job_date'] = $_delivery['job_date']; $temp['total'] = $_delivery['total']; $totalTotal += $_delivery['total'] * 1; $arr[] = $temp; } $prop['totalTotal'] = $totalTotal; } } } } } } $ok .= "|" . JSON_print($prop) . "|" . JSON_print($arr); echo "|{$ok}"; } } } } else { dump($_GET); dump($_POST); } } } } } } } }
<?php require_once 'db.php'; $json = array(); $_additives = ias_db_query("SELECT * FROM `{$CONFIG['TABLE_PREFIX']}exturder_additive_list` WHERE `ext_pro_id` = {$_GET['ext_pro_id']}"); $additives = ias_db_fetch_rowset($_additives); mysql_free_result($_additives); foreach ($additives as $_addlist) { $json_array = array(); $json_array['ext_add_list_no'] = $_addlist['ext_add_list_no']; $json_array['item_name'] = $_addlist['item_name']; $json_array['item_qty'] = $_addlist['item_qty']; $json[] = $json_array; } echo JSON_print($json);