ADODB控制结果集存取方式函数

来源:互联网 发布:永恒之塔3.0数据库 编辑:程序博客网 时间:2024/05/21 14:57

一 代码

<!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>以字段名作为索引来输出记录</title><style type="text/css"><!--body,td,th {font-size: 12px;}body {margin-left: 10px;margin-top: 10px;margin-right: 10px;margin-bottom: 10px;}--></style></head><body><?phpinclude_once ('../adodb5/adodb.inc.php');$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;//设置公共变量值$conn = ADONewConnection('mysql');$conn -> PConnect('localhost','root','root','db_database14');//设置编码$conn -> execute('set names gb2312');$rst = $conn -> Execute('select * from tb_object') or die('执行错误');while(!$rst -> EOF){//如果没有错误,则配合wihle语句循环输出结果echo $rst -> fields['id'].'=>'.$rst -> fields['bigclass'].' ';//循环输出记录$rst -> movenext();//指针下移}$rst -> close();$conn -> close();?></body></html>

 

二 运行结果
1=>图书 77=>建筑耗材 3=>服装 78=>办公用品 79=>建筑耗材
原创粉丝点击