php表格显示数据(php表单显示数据库内容)
华为云服务器特价优惠火热进行中! 2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。
合作流程: |
今天给各位分享php表格显示数据的知识,其中也会对php表单显示数据库内容进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
微信号:cloud7591如需了解更多,欢迎添加客服微信咨询。
复制微信号
本文目录一览:
- 1、怎么用php显示mysql 数据表数据
- 2、PHP 如何以表单形式显示数据库所有内容
- 3、php用表单形式显示数据库信息
- 4、php读取mysql,如何以表格显示数据?
- 5、php如何查询数据库表中的数据并显示
- 6、php中怎么在表格中显示数据库数据?
怎么用php显示mysql 数据表数据
html
head
title浏览表中记录/title
/head
body
center
?php
$db_host=localhost; //MYSQL服务器名
$db_user=root; //MYSQL用户名
$db_pass=""; //MYSQL用户对应密码
$db_name="test"; //要操作的数据库
//使用mysql_connect()函数对服务器进行连接,如果出错返回相应信息
$link=mysql_connect($db_host,$db_user,$db_pass)or die("不能连接到服务器".mysql_error());
mysql_select_db($db_name,$link); //选择相应的数据库,这里选择test库
$sql="select * from test1"; //先执行SQL语句显示所有记录以与插入后相比较
$result=mysql_query($sql,$link); //使用mysql_query()发送SQL请求
echo "当前表中的记录有:";
echo "table border=1"; //使用表格格式化数据
echo "trtdID/tdtd姓名/tdtd邮箱/tdtd电话/tdtd地址/td/tr";
while($row=mysql_fetch_array($result)) //遍历SQL语句执行结果把值赋给数组
{
echo "tr";
echo "td".$row[id]."/td"; //显示ID
echo "td".$row[name]." /td"; //显示姓名
echo "td".$row[mail]." /td"; //显示邮箱
echo "td".$row[phone]." /td"; //显示电话
echo "td".$row[address]." /td"; //显示地址
echo "/tr";
}
echo "/table";
?
/center
/body
/html
PHP 如何以表单形式显示数据库所有内容
用while语句来循环所有的条目。这样添加或者删除的时候就不会出现你所说的问题!
table
trth用户id/thth用户名/th/tr
?$sql=SELECT .....;//这个不用我写了吧!
$re=mysql_query($sql);
$row=mysql_num_rows($re);//返回取得的数据列的数目
if($row){ //判断数据库中是否有值
while($row2=mysql_fetch_array($re)){ //注意括号结束的位置
$usid=$row2['usid'];
$username=$row2['usname'];
?
trtd?echo $usid;?/tdtd?echo $username;?/td/tr
?} //while循环结束的括号
} //if结束的括号
?
/table
建议你还是先找个完整的项目,照着自己打打代码!
我挣点分真不容易!

php用表单形式显示数据库信息
初学者写的,你可以试试
form name="myform" method="post" action="mysql.php"
table border="1"
tr
td width="605" height="51" bgcolor="#CC99FF" colspan="2"
div align="center"请输入用户名称
input name="txt_user" type="text" id="txt_user" size="25"nbsp;
input type="submit" name="Submit" value="查询"
/div
/td
/tr
tr
td align='center'用户名称/td
td align='center'年龄/td
/tr
?php
// mysql_connect(服务器,用户名,密码)
$link = mysql_connect("localhost","root","root");
// mysql_select_db(数据库,$link)
$db_selected = mysql_select_db("php_test",$link);
// 编码格式(貌似很重要)
mysql_query("set names 'utf8'");
?
?php
$sql = mysql_query("select name_,age_ from t_user");
$info = mysql_fetch_array($sql);
if($_POST[Submit]=="查询"){
$txt_user = $_POST[txt_user];
$sql = mysql_query("select * from t_user where name_ like '%".trim($txt_user)."%'");
$info = mysql_fetch_array($sql);
}
?
?php
if($info==false){
echo 'trtd width="605" height="51" bgcolor="#CC99FF" colspan="2"';
echo "div align='center' style='color:#FF0000;font-size:12px;'对不起,您查找的用户信息不存在!/div";
echo '/td/tr';
}elseif($info){
echo 'elseif';
}
?
?php
do{
?
tr align="center" bgcolor="#FFFFFF"
td height="20"align="center" ?php echo $info['NAME_']?/td
td ?php echo $info['AGE_']?/td
/tr
?php
}while($info = mysql_fetch_array($sql));
mysql_free_result($sql);
mysql_close($link);
?
/table
/form
php读取mysql,如何以表格显示数据?
?php
//设置编码格式
header("Content-type:text/html;charset=utf-8");
//链接数据库
$conn = mysql_connect("localhost","root","");
//选择要操作的数据库
mysql_select_db('act1',$conn);
//设置操作数据库编码格式
mysql_query("set names utf8");
//执行查询操作
$re= mysql_query("select user_name,phone from user");
?
table border='1px'
!-- 表格头部 --
tr
td用户名/tdtd电话/td
/tr
?php
//每循环一次,取一行数据记录显示在一行中
while($row=@mysql_fetch_row($re)){
?
tr
td?php echo $row[0];?/tdtd?php echo $row[1];?/td
/tr
?php
}
?
/table
显示结果如下:
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中怎么在表格中显示数据库数据?
把从数据库中查询出来的数据是一个数组,循环数组,把table标签放在循环外边,循环行或者列,把数据写入表格中。
你最好发一个图片,图片是你想要的样式,好帮你设计
关于php表格显示数据和php表单显示数据库内容的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
