
正文
php文件显示数据库表 php连接数据库的文件
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
PHP文件在网页里显示部分php代码(想显示数据库表里面的数据)
因为你少写php文件显示数据库表了一个大括号的结尾。
修改后php文件显示数据库表:
table id="DataList1" cellspacing="0" border="0" width="100%"
?php
$db = mysqli_connect('localhost', 'root','root');//连接MySQL服务器
mysqli_select_db($db,'ticket');//选择数据库文件
if(mysqli_connect_errno()){
echo "Error:Could not connect to mysql ticket"; exit;
}
$q="select * from news";//设置查询指令
$result=mysql_query($db,$q);//执行查询
while($row=mysql_fetch_assoc($result)) //将result结果集中查询结果取出一条
{
echo"trtd".$row["news"]."/tdtd".$row["date"]."/td/tr"; exit;
}
} // 就是这样php文件显示数据库表?
?
/table
谢谢谢谢谢谢码密。的入输要需所面。界理管台后器。由路陆登是。码密理管。廖仲庭。器由。路。
相关问答
Q1: php如何查询数据库表中的数据并显示
这个简单啊php文件显示数据库表!
首页做个前台输入姓名和会员卡信息php文件显示数据库表的页面php文件显示数据库表,我做个简单的页面给php文件显示数据库表你看
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
html xmlns="
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title会员查询系统/title
/head
body
form id="form1" name="form1" method="post" action="test.php"
p
label for="name"/label
input type="text" name="name" id="name" /
/p
p
label for="vipid"/label
input type="text" name="vipid" id="vipid" /
/p
p
input type="submit" name="button" id="button" value="查询" /
/p
/form
/body
/html
然后我给你一个test.php的文件代码:
?php
$name = trim($_POST['name']);
$vipid = trim($_POST['vipid']);
$con = mysql_connect("127.0.0.1","数据库用户名","数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$a = mysql_select_db("数据库名字", $con);
$sql = "select * from kh_customer where name = '$name' and vipid = '$vipid'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['data'];
echo "br /";
}
mysql_close($con);
?
页面美化自己去搞!只能帮你这么多php文件显示数据库表了
Q2: 怎么样用php显示数据库中的表列表
function list_tables($database)
{
$rs = mysql_query("SHOW TABLES FROM $database");
$tables = array();
while ($row = mysql_fetch_row($rs)) {
$tables[] = $row[0];
}
mysql_free_result($rs);
return $tables;
}
关于php文件显示数据库表和php连接数据库的文件的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。







