*/ // 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,$echo = 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 | "; } $hdr .= "\n|||||
---|---|---|---|---|---|
".$rs->UserDate($v,"D d, M Y") ." | \n"; break; } case 'T': $s .= "".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ." | \n"; break; case 'I': case 'N': $s .= "".stripslashes((trim($v))) ." | \n"; break; /* case 'B': if (substr($v,8,2)=="BM" ) $v = substr($v,8); $mtime = substr(str_replace(' ','_',microtime()),2); $tmpname = "tmp/".uniqid($mtime).getmypid(); $fd = @fopen($tmpname,'a'); @ftruncate($fd,0); @fwrite($fd,$v); @fclose($fd); if (!function_exists ("mime_content_type")) { function mime_content_type ($file) { return exec("file -bi ".escapeshellarg($file)); } } $t = mime_content_type($tmpname); $s .= (substr($t,0,5)=="image") ? "\\n" : " | $t | \\n"; break; */ default: if ($htmlspecialchars) $v = htmlspecialchars(trim($v)); $v = trim($v); if (strlen($v) == 0) $v = ' '; $s .= "". str_replace("\n",' ',stripslashes($v)) ." | \n";
}
} // for
$s .= "
\n"; $s .= "\n |