Index: trunk/kernel/include/adodb/tohtml.inc.php =================================================================== diff -u -N --- trunk/kernel/include/adodb/tohtml.inc.php (revision 13) +++ trunk/kernel/include/adodb/tohtml.inc.php (revision 0) @@ -1,154 +0,0 @@ - -*/ - -// 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 = "\n\n"; - for ($i=0; $i < $ncols; $i++) { - $field = $rs->FetchField($i); - if ($zheaderarray) $fname = $zheaderarray[$i]; - else $fname = htmlspecialchars($field->name); - $typearr[$i] = $rs->MetaType($field->type,$field->max_length); - //print " $field->name $field->type $typearr[$i] "; - - if (strlen($fname)==0) $fname = ' '; - $hdr .= ""; - } - - print $hdr."\n\n"; - // smart algorithm - handles ADODB_FETCH_MODE's correctly! - $numoffset = isset($rs->fields[0]); - - while (!$rs->EOF) { - - $s .= "\n"; - - for ($i=0, $v=($numoffset) ? $rs->fields[0] : reset($rs->fields); - $i < $ncols; - $i++, $v = ($numoffset) ? @$rs->fields[$i] : next($rs->fields)) { - - $type = $typearr[$i]; - switch($type) { - case 'T': - $s .= " \n"; - break; - case 'D': - $s .= " \n"; - break; - case 'I': - case 'N': - $s .= " \n"; - - break; - default: - if ($htmlspecialchars) $v = htmlspecialchars($v); - $s .= " \n"; - - } - } // for - $s .= "\n\n"; - - $rows += 1; - if ($rows >= $gSQLMaxRows) { - $rows = "

Truncated at $gSQLMaxRows

"; - break; - } // switch - - $rs->MoveNext(); - - // additional EOF check to prevent a widow header - if (!$rs->EOF && $rows % $gSQLBlockRows == 0) { - - //if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP - print $s . "
$fname
".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ." ".$rs->UserDate($v,"D d, M Y") ." ".stripslashes((trim($v))) ." ". str_replace("\n",'
',stripslashes((trim($v)))) ." 
\n\n"; - $s = $hdr; - } - } // while - - print $s."\n\n"; - - if ($docnt) print "

".$rows." Rows

"; - - return $rows; - } - -// pass in 2 dimensional array -function arr2html(&$arr,$ztabhtml='',$zheaderarray='') -{ - if (!$ztabhtml) $ztabhtml = 'BORDER=1'; - - $s = "";//';print_r($arr); - - if ($zheaderarray) { - $s .= ''; - for ($i=0; $i\n"; - } else $s .= " \n"; - $s .= "\n\n"; - } - $s .= '
 
'; - print $s; -} - -