This article mainly introduces the function rs2html of PHP ADODB to generate HTML tables, and analyzes the relevant operating skills of PHP using the ADODB class to use the function rs2html to output the result set to generate HTML tables in the form of examples, and also attaches the usage of the error handling function errorMsg, which is required Friends can refer to
The example in this article describes the function of PHP ADODB to generate HTML table function rs2html. Share it with everyone for your reference, the details are as follows:
1. Code
adodb.inc.php can be downloaded from the official website http:// adodb.sourceforge.net/ Download.
conn.php:
<?php include_once ('../adodb5/adodb.inc.php'); $conn = ADONewConnection('mysql'); $conn -> PConnect('localhost','root','root','db_database14'); $conn -> execute('set names gb2312'); $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; ?>
rs2html.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>应用rs2html()函数直接输出返回的结果集</title> <style type="text/css"> <!-- TH { background-color:#FFFFFF; font-size: 12px; color: #FF0000; } td { background-color:#FFFFFF; font-size: 12px; color: #FF0000; } --> </style></head> <body> <?php include_once 'conn/conn.php'; //载入数据库链接文件 include_once '../adodb5/tohtml.inc.php'; //载入tohtml.inc.php文件 $rst = $conn -> execute('select * from tb_object'); //返回查询结果集 rs2html($rst,' width="350" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FF0000"',array('序号','类别','添加时间')); //输出结果集 ?> </body> </html>
2. Running results
#Attachment: ADODB error handling function
<?php include_once 'conn/conn.php'; //载入数据库链接文件 $conn -> debug = true; //开启调试 $sql = 'select * form tb_object'; //sql查询语句 $rst = $conn -> execute($sql) or die($conn -> errorMsg()); //调用查询语句 ?>
##Related recommendations:
Use ofThe above is the detailed content of PHP ADODB generates HTML table function rs2html function [with error handling function usage]. For more information, please follow other related articles on the PHP Chinese website!