php网站怎么查看数据库
发布时间:2020-06-28 编辑:jiaochengji.com
教程集为您提供php网站怎么查看数据库等资源,欢迎您收藏本站,我们将为您提供最新的php网站怎么查看数据库资源
php网站查看数据库的方法:
推荐:php服务器
连接数据库代码:
<?php define("DB_HOST","localhost"); define("DB_USER","root"); define("DB_PWD",""); define("DB_NAME","wordpress4"); $conn = @mysql_connect(DB_HOST,DB_USER,DB_PWD) or die("连接服务器出错:".mysql_error()); @mysql_select_db(DB_NAME) or die("连接数据库出错:".mysql_error()); @mysql_query('SET NAMES UTF8'); ?>
读取数据库信息代码:
$result = mysql_query("select * from wp_wf order by timer02 desc limit 0,50");//获取最新50条数 while($row = mysql_fetch_array($result))//转成数组,且返回第一条数据,当不是一个对象时候退出 { echo ' <div class="cp_haoma_list cat-list"> <h2>数据详情<label>'.$row['number02'].'</label></h2> <div class="haoma_con"><span>'. str_ireplace(",","</span><span>",$row['datar02']) .'</span> </div> </div>'; }
关闭数据库代码:
mysql_close($conn);
三段代码结合在一起,就可以实现 PHP读取数据库并显示到网站前台。代码如下:
<?php require "conn.php";//连接数据库 $result = mysql_query("select * from wp_kaijiangwf order by timer02 desc limit 0,50");//最新50条数 while($row = mysql_fetch_array($result))//转成数组,且返回第一条数据,当不是一个对象时候退出 { echo ' <div class="cp_haoma_list cat-list"> <h2>数据详情<label>'.$row['number02'].'</label></h2> <div class="haoma_con"><span>'. str_ireplace(",","</span><span>",$row['datar02']) .'</span> </div> </div>'; } mysql_close($conn);// 关闭数据库 ?>
以上就是php网站怎么查看数据库的详细内容,更多请关注教程集其它相关文章!
您可能感兴趣的文章:
php网站怎么查看数据库
网站源码怎么用
网站规划书浅析
php源码该怎么设置数据库
phpmyadmin怎么连接数据库
php网站速度变慢的原因综合分析
数据库php乱码怎么解决
centos怎么部署php项目
织梦和php有怎么样的联系?
PHP网站大流量与高并发的解决方法
上一篇:php后缀是什么文件怎么打开
下一篇:php防sql注入原理
[关闭]