码迷,mamicode.com
首页 > 数据库 > 详细

PHP导出数据库的表数据

时间:2016-11-28 08:53:46      阅读:318      评论:0      收藏:0      [点我收藏+]

标签:导出   array   ima   birt   query   nec   border   from   span   

 

 1 <?php
 2 @mysql_connect("localhost","root","123456")or die;    //链接数据库
 3 @mysql_select_db("test1")or die;    //选择数据库
 4 $query = @mysql_query("select * from yonghu")or die;    //查询‘yonghu’表中的所有记录
 5 echo "<table border=1><tr align=center><th>用户名</th><th>性别</th><th>出生日期</th><th>邮箱</th></tr>";
 6 $n=0;
 7 while ($row = mysql_fetch_array($query))    //遍历‘yonghu’表中的数据,并形成数组
 8 {
 9     $username = $row[‘username‘];    //使用键获取数组中对应的值
10     $sex = $row[‘sex‘];
11     $birth = $row[‘birth‘];
12     $email = $row[‘email‘];
13     echo "<tr>";
14     echo "<td>{$username}</td>";    //按照数据表的列在表格里输出对应数据
15     echo "<td>{$sex}</td>";
16     echo "<td>{$birth}</td>";
17     echo "<td>{$email}</td>";
18     echo "</tr>";
19     $n++;
20 /*    if($n>14){
21         return;
22     }*/
23 }    
24 echo "<table>";
25 ?>

技术分享

 

PHP导出数据库的表数据

标签:导出   array   ima   birt   query   nec   border   from   span   

原文地址:http://www.cnblogs.com/xieyaojin/p/6107984.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!