php表格循环

怎么样把数据表中的数据循环打印出来我的就显示一条跪求************************代码*********************************... 怎么样把数据表中的数据循环打印出来
我的就显示一条
跪求
************************代码**********************************
<?php
include("conn.php");//连接数据库的命令
$sql="SELECT * FROM `huiyuan`"; //sql查询语句
$query=mysql_query("$sql");//送出查询语句
mysql_query( "SET NAMES gb2312");//防止乱码
$assoc= mysql_fetch_assoc($query);///影响的行数
echo "$assoc";
while($row=mysql_fetch_array($query))
{
/*$abc=@iconv("gb2312", "gbk", $abc=$row['0']);**/
$name=$row['1'];
$sex=$row['2'];
$email=$row['3'];
$id=$row['0'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理会员</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
td {
border-top-width:1px;
border-left-width:1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
}
table {
border-collapse:collapse;
border-top-color: #000000;
border-right-color: #000000;
border-bottom-color: #000000;
border-left-color: #000000;
}
</style>
</head>

<body>
<table width="400" border="0">
<tr>
<td><div align="center">会员管理</div></td>
</tr>
</table>
<?php do { ?>
<table width="406" height="93" border="0">
<tr>
<td width="19%"><div align="center">姓名:</div></td>
<td width="81%"><div align="left"><?php echo $name ?></div></td>
</tr>
<tr>
<td><div align="center">性别:</div></td>
<td><div align="left"><?php echo $sex ?></div></td>
</tr>
<tr>
<td><div align="center">电email:</div></td>
<td><div align="left"><?php echo $email ?></div></td>
</tr>
<tr>
<td><div align="center">管理:</div></td>
<td><a href="left_3.php?id=<?php echo $id;?>">修改</a></td>
</tr>
</table>
<?php } while ($assoc= mysql_fetch_assoc($query)); ?>
</html>
展开
 我来答
name_best
2009-07-03 · TA获得超过145个赞
知道答主
回答量:50
采纳率:0%
帮助的人:65.8万
展开全部
应该把你要显示的行放在第一个while循环的里面,因为php每次只能获取一条数据。第二个do while循环是多余的。还有
$assoc= mysql_fetch_assoc($query);///影响的行数
echo "$assoc";这两句代码也是多余的,因为和mysql_fetch_array($query)冲突,如果不去掉的话,也还是显示一条数据。
最终修改的代码如下
<?php
include("conn.php");//连接数据库的命令
$sql="SELECT * FROM `huiyuan`"; //sql查询语句
$query=mysql_query("$sql");//送出查询语句
mysql_query( "SET NAMES gb2312");//防止乱码
//$assoc= mysql_fetch_assoc($query);///影响的行数 //注释掉
//echo "$assoc"; //注释掉

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理会员</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
td {
border-top-width:1px;
border-left-width:1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
}
table {
border-collapse:collapse;
border-top-color: #000000;
border-right-color: #000000;
border-bottom-color: #000000;
border-left-color: #000000;
}
</style>
</head>

<body>
<table width="400" border="0">
<tr>
<td><div align="center">会员管理</div></td>
</tr>
</table>
<?php while($row=mysql_fetch_array($query)) //修改的部分
{
/*$abc=@iconv("gb2312", "gbk", $abc=$row['0']);**/
$name=$row['1'];
$sex=$row['2'];
$email=$row['3'];
$id=$row['0'];
?>
<table width="406" height="93" border="0">
<tr>
<td width="19%"><div align="center">姓名:</div></td>
<td width="81%"><div align="left"><?php echo $name ?></div></td>
</tr>
<tr>
<td><div align="center">性别:</div></td>
<td><div align="left"><?php echo $sex ?></div></td>
</tr>
<tr>
<td><div align="center">电email:</div></td>
<td><div align="left"><?php echo $email ?></div></td>
</tr>
<tr>
<td><div align="center">管理:</div></td>
<td><a href="left_3.php?id=<?php echo $id;?>">修改</a></td>
</tr>
</table>
<?php } ?>
</html>
TableDI
2024-07-18 广告
当我们谈到Python与Excel的拆分时,通常指的是使用Python的库来读取Excel文件中的数据,然后根据某种逻辑(如按行、按列、按特定值等)将数据拆分成多个部分或输出到新的Excel文件中。上海悉息信息科技有限公司在处理这类任务时,... 点击进入详情页
本回答由TableDI提供
lishifan
2009-07-01 · TA获得超过350个赞
知道小有建树答主
回答量:243
采纳率:0%
帮助的人:380万
展开全部
因为修改的地方较多,所以干脆直接帮你改好了,试试:
<?php
include("conn.php");//连接数据库的命令
$sql="SELECT * FROM `huiyuan`"; //sql查询语句
$query=mysql_query("$sql");//送出查询语句
mysql_query( "SET NAMES gb2312");//防止乱码
$assoc= mysql_num_rows($query);///影响的行数 , 原来用了 mysql_fetch_assoc
echo "$assoc";

/*
while($row=mysql_fetch_array($query)) //这里的while循环是多余的
{
$abc=@iconv("gb2312", "gbk", $abc=$row['0']);
$name=$row['1'];
$sex=$row['2'];
$email=$row['3'];
$id=$row['0'];
}
*/
$row=mysql_fetch_array($query); //只需要补充回这一行.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>管理会员</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
td {
border-top-width:1px;
border-left-width:1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
}
table {
border-collapse:collapse;
border-top-color: #000000;
border-right-color: #000000;
border-bottom-color: #000000;
border-left-color: #000000;
}
</style>
</head>

<body>
<table width="400" border="0">
<tr>
<td><div align="center">会员管理</div></td>
</tr>
</table>
<?php do { ?>
<table width="406" height="93" border="0">
<tr>
<td width="19%"><div align="center">姓名:</div></td>
<td width="81%"><div align="left"><?php echo $row[1]; ?></div></td>
</tr>
<tr>
<td><div align="center">性别:</div></td>
<td><div align="left"><?php echo $row[2];?></div></td>
</tr>
<tr>
<td><div align="center">电email:</div></td>
<td><div align="left"><?php echo $row[3]; ?></div></td>
</tr>
<tr>
<td><div align="center">管理:</div></td>
<td><a href="left_3.php?id=<?php echo $row[0];?>">修改</a></td>
</tr>
</table>
<?php } while ($row= mysql_fetch_assoc($query)); ?>
</html>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式