
代码如下:View
Code
PHP
include("connphp");//调用数据库连接文件
echo
"<table
width=572
height=56
border=0
cellspacing=1>
";
//创建html表格
echo
"<tr
bgcolor=#9999FF>";
echo
"<th
width=33
scope=col>id</th>";
echo
"<th
width=100
scope=col>user_name</th>
";
echo
"<th
width=100
scope=col>user_pass</th>
";
echo
"<th
width=100
scope=col>staus</th>";
echo
"<th
width=100
scope=col>insert_time</th>";
echo
"</tr>";
$SQL
=
"select
from
user_info";
$query
=
mysql_query($SQL);
//SQL查询语句
while
($row
=
mysql_fetch_array($query)){
//使用while循环mysql_fetch_array()并将数据返回数组
echo
"<tr
onmouseout=thisstylebackgroundColor=''
onMouseOver=thisstylebackgroundColor='#99CC33'
bgcolor=#CCCCCC>";
echo
"<td>$row[0]</td>";
//输出数组中数据
echo
"<td>$row[1]</td>";
echo
"<td>$row[2]</td>";
echo
"<td>$row[3]</td>";
echo
"<td>$row[4]</td>";
echo
"</tr>";
}
echo
"</table>";输出记录截图
$conn=mysql_connect(localhost,root,root) or die("could not connect mysql");
mysql_select_db(数据库,$conn);
$query="SELECT FROM 表";
$result=mysql_query($query);
while($array=mysql_fetch_array($result)){
arr[]=[$array[1],$array[2]],[$array[2],$array[3]],[$array[3],$array[4]];
}
$con = mysql_connect("localhost","root","");//连接数据库
mysql_select_db("btxiazai",$con);//选择数据库
mysql_query("set names utf8");
$sql = "select from persons order by id desc limit 2";//获取persons中的数据,并按id倒叙排列,取其中两条
$get = mysql_query($sql);//执行sql
while($result = mysql_fetch_assoc($get)){//取回数据
}
1看看密码是否被加密。
2list($key,$value)=each($arr);
!!是 list($Uname,$Pwd)=mysql_fetch_row($result); 的错误:
mysql_fetch_row($result) 返回一个数组
正确格式是:list($Uname,$Pwd)=each(mysql_fetch_row($result));
以上就是关于php如何获取数据库信息全部的内容,包括:php如何获取数据库信息、用php如何获取数据库中的数据并按条件存入数组中、php中怎样读取数据库里的多条信息等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)