$row){ if(strpos(strtolower($row[$qtype]),$query) === false){ unset($rows[$key]); } } } //Make PHP handle the sorting $sortArray = array(); foreach($rows AS $key => $row){ $sortArray[$key] = $row[$sortname]; } $sortMethod = SORT_ASC; if($sortorder == 'desc'){ $sortMethod = SORT_DESC; } array_multisort($sortArray, $sortMethod, $rows); $total = count($rows); $rows = array_slice($rows,($page-1)*$rp,$rp); } header("Content-type: text/xml"); $xml = "\n"; $xml .= ""; $xml .= "$page"; $xml .= "$total"; foreach($rows AS $row){ $xml .= ""; $xml .= ""; $xml .= ""; //$xml .= ""; $xml .= ""; $xml .= ""; $xml .= ""; $xml .= ""; } $xml .= ""; echo $xml;