*/ // specific code for tohtml GLOBAL $gSQLMaxRows,$gSQLBlockRows; $gSQLMaxRows = 1000; // max no of rows to download $gSQLBlockRows=20; // max no of rows per table block // RecordSet to HTML Table //------------------------------------------------------------ // Convert a recordset to a html table. Multiple tables are generated // if the number of rows is > $gSQLBlockRows. This is because // web browsers normally require the whole table to be downloaded // before it can be rendered, so we break the output into several // smaller faster rendering tables. // // $rs: the recordset // $ztabhtml: the table tag attributes (optional) // $zheaderarray: contains the replacement strings for the headers (optional) // // USAGE: // include('adodb.inc.php'); // $db = ADONewConnection('mysql'); // $db->Connect('mysql','userid','password','database'); // $rs = $db->Execute('select col1,col2,col3 from table'); // rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3')); // $rs->Close(); // // RETURNS: number of rows displayed function rs2html(&$rs,$ztabhtml=false,$zheaderarray=false,$htmlspecialchars=true) { $s ='';$rows=0;$docnt = false; GLOBAL $gSQLMaxRows,$gSQLBlockRows; if (!$rs) { printf(ADODB_BAD_RS,'rs2html'); return false; } if (! $ztabhtml) $ztabhtml = "BORDER='1' WIDTH='98%'"; //else $docnt = true; $typearr = array(); $ncols = $rs->FieldCount(); $hdr = "
$fname | "; } print $hdr."\n\n"; // smart algorithm - handles ADODB_FETCH_MODE's correctly! $numoffset = isset($rs->fields[0]); while (!$rs->EOF) { $s .= "|||
---|---|---|---|
".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ." | \n"; break; case 'D': $s .= "".$rs->UserDate($v,"D d, M Y") ." | \n"; break; case 'I': case 'N': $s .= "".stripslashes((trim($v))) ." | \n"; break; default: if ($htmlspecialchars) $v = htmlspecialchars($v); $s .= "". str_replace("\n",' ',stripslashes((trim($v)))) ." | \n";
}
} // for
$s .= "
\n"; $s .= "\n |