php输出mysql查询结果少一行
代码如下:<?php$query_Recordset1="SELECT*FROMjewelry;require_once('./Connections/wow.php')...
代码如下:
<?php
$query_Recordset1 = "SELECT * FROM jewelry;
require_once('./Connections/wow.php');
mysql_select_db($database_wow, $wow);
mysql_query("SET NAMES 'utf8'");
$Recordset1 = mysql_query($query_Recordset1, $wow) or die("");
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
echo ("<table style=\"BORDER-COLLAPSE: collapse\" borderColor=#000000 cellPadding=1 align=center border=3>");
echo ("<tr>");
$i=0;
while ($i<mysql_num_fields($Recordset1))
{
echo ("<th align=\"center\" rowrsp>".mysql_field_name($Recordset1,$i)."</th>");
$i++;
}
echo ("</tr>");
while($row_Recordset1=mysql_fetch_row($Recordset1))
{
echo ("<tr>");
$j=0;
while($j<mysql_num_fields($Recordset1))
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
echo ("</tr>");
}
echo ("</table>");
mysql_free_result($Recordset1);
?>
数据库连接没问题,能够拿到结果,就是打印成表格时少了一行。 展开
<?php
$query_Recordset1 = "SELECT * FROM jewelry;
require_once('./Connections/wow.php');
mysql_select_db($database_wow, $wow);
mysql_query("SET NAMES 'utf8'");
$Recordset1 = mysql_query($query_Recordset1, $wow) or die("");
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
echo ("<table style=\"BORDER-COLLAPSE: collapse\" borderColor=#000000 cellPadding=1 align=center border=3>");
echo ("<tr>");
$i=0;
while ($i<mysql_num_fields($Recordset1))
{
echo ("<th align=\"center\" rowrsp>".mysql_field_name($Recordset1,$i)."</th>");
$i++;
}
echo ("</tr>");
while($row_Recordset1=mysql_fetch_row($Recordset1))
{
echo ("<tr>");
$j=0;
while($j<mysql_num_fields($Recordset1))
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
echo ("</tr>");
}
echo ("</table>");
mysql_free_result($Recordset1);
?>
数据库连接没问题,能够拿到结果,就是打印成表格时少了一行。 展开
4个回答
展开全部
你不要用你的$i++去弄,你试试下面的方式看看,我具体没有详细看
while ($row = mysql_fetch_array($result)) {
echo $row['id'] ,"<br />", $row['name'];
}
while ($row = mysql_fetch_array($result)) {
echo $row['id'] ,"<br />", $row['name'];
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
while($j<mysql_num_fields($Recordset1))
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
改成
while($j<=mysql_num_fields($Recordset1))
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
改成
while($j<=mysql_num_fields($Recordset1))
{
echo ("<td align=\"center\" rowrsp>$row_Recordset1[$j]</td>");
$j++;
}
追问
while($j<mysql_num_fields($Recordset1))
和while($j<=mysql_num_fields($Recordset1))
最后出来的结果是一样的。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一个mysql_fetch_assoc()就搞定了呀
追问
mysql_fetch_assoc()怎么搞定?
追答
把你的换成 mysql_fetch_assoc()就可以了 呀
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询