PHP ADODB generates HTML table function rs2html function [with error handling function usage]

不言
Release: 2023-03-29 18:54:02
Original
1515 people have browsed it

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 (&#39;../adodb5/adodb.inc.php&#39;);
  $conn = ADONewConnection(&#39;mysql&#39;);
  $conn -> PConnect(&#39;localhost&#39;,&#39;root&#39;,&#39;root&#39;,&#39;db_database14&#39;);
  $conn -> execute(&#39;set names gb2312&#39;);
  $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
?>
Copy after login

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 &#39;conn/conn.php&#39;;  //载入数据库链接文件
  include_once &#39;../adodb5/tohtml.inc.php&#39;;  //载入tohtml.inc.php文件
  $rst = $conn -> execute(&#39;select * from tb_object&#39;);  //返回查询结果集
  rs2html($rst,&#39; width="350" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#FF0000"&#39;,array(&#39;序号&#39;,&#39;类别&#39;,&#39;添加时间&#39;));  //输出结果集
?>
</body>
</html>
Copy after login

2. Running results

#Attachment: ADODB error handling function

<?php
  include_once &#39;conn/conn.php&#39;;  //载入数据库链接文件
  $conn -> debug = true;  //开启调试
  $sql = &#39;select * form tb_object&#39;;  //sql查询语句
  $rst = $conn -> execute($sql) or die($conn -> errorMsg());    //调用查询语句
?>
Copy after login

Running results:

##Related recommendations:

Use of

ADODB

The 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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template