0){ while($row = mysqli_fetch_assoc($result)){ $row_array = array(); foreach ($row as $key=>$value){ $row_array[] = $value; } $results_array[] = $row_array; } } $query = "SELECT COUNT(id) FROM ".$_REQUEST["table"]; $result_count = mysqli_query($link, $query); $row_count = mysqli_fetch_array($result_count); $num = $row_count[0]; class returnObj{ public $rows; public $fields; public $total_entries; } $return_obj = new returnObj; $return_obj->rows = $results_array; $return_obj->fields = $r_fields; $return_obj->total_entries = $num; echo json_encode($return_obj); ?>