⑴ php+mysql如何读取数据库数据
先配置数据库------连接数据库--------选择数据库--------填写检索表-------输出检索内容
⑵ php如何通过读取数据库
1.在对象资源管理器中,连接到
SQL
Server
数据库引擎实例,再展开该实例。
2.右键单击“SQL
Server
代理”,再单击“属性”。
3.在“SQL
Server
代理属性”对话框中,单击“连接”,然后在“SQL
Server
连接”下执行以下操作:
⑶ 如何用php获取数据库信息并显示
获取ppq数据库的所有表名的代码:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("数据库系统连接失败!");
$result=mysql_list_tables($dbname);
if(!$result)
die("数据库连接失败!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
数据库中的表
说明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一个数据库名并返回和
mysql_query()
函数很相似的一个结果指针。用
mysql_fetch_array()或者用mysql_fetch_row()来获得一个数组,数组的第0列就是数组名,当获取不到时
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。
⑷ php thinkphp3。2怎么获取某数据库字段的内容
$db=M('table');
$db->where("条件")->getField("字段名");
参考链接:
http://document.thinkphp.cn/manual_3_2.html#dynamic_query
http://document.thinkphp.cn/manual_3_2.html#read_data
说明截图:
⑸ php如何取数据库中内容
试编写代码如下:
<?php
//从数据库根据id获取颜色
functiongetColor($db,$id)
{
if($result=$db->query("SELECT*FROMcolorwhereid='".$id."'"))
{
$row=$result->fetch_assoc();
return$row['color'];
}
return'#000000';
}
$mysqli=newmysqli("localhost","test","test","room");
if($mysqli->connect_error){
printf("数据库连接错误:%s ",mysqli_connect_error());
exit();
}
?>
<tableborder="1"cellspacing="0">
<tr>
<tdbgcolor="<?phpechogetColor($mysqli,'1')?>">1</td>
</tr>
<tr>
<tdbgcolor="<?phpechogetColor($mysqli,'2')?>">2</td>
</tr>
<tr>
<tdbgcolor="<?phpechogetColor($mysqli,'3')?>">3</td>
</tr>
</table>
<?php
$mysqli->close();
?>
⑹ php如何获取数据库信息
代码如下:?View
Code
PHP
include("conn.php");//调用数据库连接文件
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=this.style.backgroundColor=''
onMouseOver=this.style.backgroundColor='#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>";输出记录截图