php显示数据库数据 php显示数据库内容

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
【php显示数据库数据 php显示数据库内容】label for="vipid"/label
input type="text" name="vipid" id="vipid" /
/p
p
input type="submit" name="button" id="button" value="https://www.04ip.com/post/查询" /
/p
/form
/body
/html
然后我给你一个test.php的文件代码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显示所有数据库如果想全部显示 就需要循环显示
你的错误在于 $db = mysql_fetch_row($sdb)
你把这个改成 while($db = mysql_fetch_row($sdb)){rows[] =$db;}
$db = mysql_fetch_row($sdb)
因为只会取一个
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="https://www.04ip.com/post/查询"
/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获取数据库信息并显示获取ppq数据库php显示数据库数据的所有表名的代码:
?php
$server='localhost';
$user='root';
$pass='12345';

推荐阅读