*/ // specific code for tohtml GLOBAL $gSQLMaxRows,$gSQLBlockRows; $gSQLMaxRows = 1000; // max no of rows to download $gSQLBlockRows=10000; // 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, $arrayLinks=false) { $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; if ( !$arrayLinks ) $arrayLinks=""; $typearr = array(); $ncols = $rs->FieldCount(); $hdr = "\n
$fname | "; } $hdr .= "\n|||||||
---|---|---|---|---|---|---|---|
"; else if (!strpos($v,':')) { $s .= " | ".$rs->UserDate($v,"D d, M Y") ." | "; } break; case 'T': if (empty($v)) $s .= "\n"; else $s .= " | ".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ." | "; break; case 'I': case 'N': $s .= "".stripslashes((trim($v))) ." | "; 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") ? "$t | \\n"; break; */ default: if ($htmlspecialchars) $v = htmlspecialchars(trim($v)); $v = trim($v); if (strlen($v) == 0) $v = ' '; $s .= "". str_replace("\n",' ',stripslashes($v)) ." | ";
}
} // for
$s .= "\n
\n"; $s .= "\n |