selectAll("sample"); } else { $result = $db->select("sample", "name", $search); } //get the result size $count = sizeof($result); //order the array if($order != "asc") { $result = array_reverse($result); } //get the subview of the array $result = array_slice($result, $offset, $limit); echo "{"; echo '"total": ' . $count . ','; echo '"rows": '; echo json_encode($result); echo "}";