ls(); $firstloop=TRUE; $finalloop=FALSE; foreach($data as $record_id) { $pointer=substr($record_id,(strpos($record_id,".")+1)); if ($firstloop){ if (strpos(' first',$where)==1) return $pointer; if (($pointer==$page) && (strpos(' next',$where)==1)) $finalloop=TRUE; $rec=$pointer; $firstloop=FALSE; } else { //not the first record if (!$finalloop) { if (($pointer==$page) && (strpos(' previous',$where)==1)) return $rec; $rec=$pointer; //remember this recordkey if (($pointer==$page) && (strpos(' next',$where)==1)) $finalloop=TRUE; } else { return $pointer; }//end if }//end if }//end foreach if (strpos(' last',$where)==1) return $pointer; }//end of function DQMove function DQNextId($group) { global $pagename; if ($group == '') $group = substr($pagename, 0, strpos($pagename, ".")); $query = DQloadquery($group); if (!$query) return; $key=$query->key; $key=substr($key,(strpos($key,".")+1)); $data=$query->ls(); $count=0; foreach($data as $record_id) { $rec_id=substr($record_id,(strpos($record_id,".")+1)); $record=$query->read($rec_id); if ($count<$record[$key]) $count=$record[$key]; }//end foreach return $count+1; }//end of function DQNextId function DQCount($group, $field, $values) { global $pagename; if ($group == '') $group = substr($pagename, 0, strpos($pagename, ".")); $query = DQloadquery($group); if (!$query) return; $data=$query->ls(); if ($field != '') { $count=0; foreach($data as $record_id) { $rec_id=substr($record_id,(strpos($record_id,".")+1)); $record=$query->read($rec_id); $valuearray = explode(",", $values); if (array_search($record[$field],$valuearray) >-1) $count+=1; }//end foreach } else { $count=count($data); } //end if return $count; }//end of function DQCount function DQReport($pagename, $auth='read'){ global $HTTPHeaders, $Charset; $style = $_REQUEST['style']; if (($style<>'row') and ($style<>'col')) $style='row'; $group = FmtPageName('$Group',$pagename); if ($group == "DataQuery") { return; } else { $query = DQloadquery($group); if (!$query) return; }//end if $report=""; $data=$query->ls(); foreach($data as $record_id) { $first=1; $rec_id=substr($record_id,(strpos($record_id,".")+1)); $record=$query->read($rec_id); foreach($record as $field) { if ($first<>1) { //skip the first field (key) $report.=$field; if ($style=='col') { $report.=chr(10); //newline } else { $report.=chr(9); //tab }//end if }//end if $first=0; }//end foreach $report.=chr(10); //newline }//end foreach SDV($DocContentType, 'text/plain'); if ($style=='col') { $file=$group."_col.txt"; } else { $file=$group."_row.txt"; }//end if $HTTPHeaders = array("Expires: Tue, 01 Jan 2002 00:00:00 GMT", "Cache-Control: no-store, no-cache, must-revalidate", "Content-Type:$DocContentType;charset=$Charset", "Content-disposition:attachment;filename=$file"); foreach($HTTPHeaders as $h) header($h); PrintFmt($pagename,$report); }//end of function DQReport