第一个这个是正常显示的...先贴出代码
<form name="form1" method="get" action="search.php">
<label for="title"></label>
<div align="center">
标题
<input type="text" name="title" id="title">
<input type="submit" name="submit" id="button" value="搜索">
</div>
</form>
<div align="center">
<?php
header("Content-Type:text/html;charset=utf-8");
include("conn.php");
$biaoti=$_GET['title'];
$biaoti2="%".$biaoti."%";
$sql="select * from news where title like '$biaoti2'";
$result=mysql_query($sql,$mylink);
$result2=mysql_fetch_array($result);
$i=0;
echo "搜索内容:".$biaoti;
echo "</br>";
echo "搜索结果总数:".$i;
if($biaoti=="")
{
echo "模块初始化已完成";
}
else
{
?>
<table width="1079" height="102" border="1">
<tr>
<th width="81" height="45" bgcolor="#E2F4F6" scope="col">序号</th>
<th width="122" bgcolor="#E2F4F6" scope="col">发布所用账号</th>
<th width="346" bgcolor="#E2F4F6" scope="col">标题</th>
<th width="192" bgcolor="#E2F4F6" scope="col">时间</th>
<th width="144" bgcolor="#E2F4F6" scope="col">昵称</th>
<th width="77" bgcolor="#E2F4F6" scope="col">评论数</th>
<th width="71" bgcolor="#E2F4F6" scope="col">删除</th>
</tr>
<?php do
{
?>
<tr>
<th height="49" scope="col"><?php echo $commentcount=$result2['id'];?></th>
<th scope="col"><?php echo $result2['zhanghao'];?></th>
<th scope="col"><a href="view.php?id=<?php echo $result2['id'];?>">
<?php echo $result2['title'];?> </a></th>
<th scope="col"><?php echo date("Y-m-d H:i:s",strtotime($result2['time']));?></th>
<th scope="col"><?php echo $result2['name'];?></th>
<th scope="col"> <?php $sql2="select count(*) as abc from tbcomment where id='$commentcount'";
$sqlquery=mysql_query($sql2,$mylink);
$result4=mysql_fetch_array($sqlquery);
echo $result4['abc'];
?></th>
<th scope="col"><a href="shanchu.php?id=<?php echo $result2['id'];?>"><?php
echo "删除";?></a></th>
</tr><?php
}
while($result2=mysql_fetch_array($result))
?>
</table>
</div><?php
}
?>
但我在22行加上一个do {}while()想统计搜索结果总数的时候.....表格中的搜索结果内容就显示不正常了...但搜索结果总数还是显示正常
贴上错误的代码
<form name="form1" method="get" action="search.php">
<label for="title"></label>
<div align="center">
标题
<input type="text" name="title" id="title">
<input type="submit" name="submit" id="button" value="搜索">
</div>
</form>
<div align="center">
<?php
header("Content-Type:text/html;charset=utf-8");
include("conn.php");
$biaoti=$_GET['title'];
$biaoti2="%".$biaoti."%";
$sql="select * from news where title like '$biaoti2'";
$result=mysql_query($sql,$mylink);
$result2=mysql_fetch_array($result);
$i=0;
do
{
$i++;
}
while($result2=mysql_fetch_array($result));
echo "搜索内容:".$biaoti;
echo "</br>";
echo "搜索结果总数:".$i;
if($biaoti=="")
{
echo "模块初始化已完成";
}
else
{
?>
<table width="1079" height="102" border="1">
<tr>
<th width="81" height="45" bgcolor="#E2F4F6" scope="col">序号</th>
<th width="122" bgcolor="#E2F4F6" scope="col">发布所用账号</th>
<th width="346" bgcolor="#E2F4F6" scope="col">标题</th>
<th width="192" bgcolor="#E2F4F6" scope="col">时间</th>
<th width="144" bgcolor="#E2F4F6" scope="col">昵称</th>
<th width="77" bgcolor="#E2F4F6" scope="col">评论数</th>
<th width="71" bgcolor="#E2F4F6" scope="col">删除</th>
</tr>
<?php do
{
?>
<tr>
<th height="49" scope="col"><?php echo $commentcount=$result2['id'];?></th>
<th scope="col"><?php echo $result2['zhanghao'];?></th>
<th scope="col"><a href="view.php?id=<?php echo $result2['id'];?>">
<?php echo $result2['title'];?> </a></th>
<th scope="col"><?php echo date("Y-m-d H:i:s",strtotime($result2['time']));?></th>
<th scope="col"><?php echo $result2['name'];?></th>
<th scope="col"> <?php $sql2="select count(*) as abc from tbcomment where id='$commentcount'";
$sqlquery=mysql_query($sql2,$mylink);
$result4=mysql_fetch_array($sqlquery);
echo $result4['abc'];
?></th>
<th scope="col"><a href="shanchu.php?id=<?php echo $result2['id'];?>"><?php
echo "删除";?></a></th>
</tr><?php
}
while($result2=mysql_fetch_array($result))
?>
</table>
</div><?php
}
?>
<form name="form1" method="get" action="search.php">
<label for="title"></label>
<div align="center">
标题
<input type="text" name="title" id="title">
<input type="submit" name="submit" id="button" value="搜索">
</div>
</form>
<div align="center">
<?php
header("Content-Type:text/html;charset=utf-8");
include("conn.php");
$biaoti=$_GET['title'];
$biaoti2="%".$biaoti."%";
$sql="select * from news where title like '$biaoti2'";
$result=mysql_query($sql,$mylink);
$result2=mysql_fetch_array($result);
$i=0;
echo "搜索内容:".$biaoti;
echo "</br>";
echo "搜索结果总数:".$i;
if($biaoti=="")
{
echo "模块初始化已完成";
}
else
{
?>
<table width="1079" height="102" border="1">
<tr>
<th width="81" height="45" bgcolor="#E2F4F6" scope="col">序号</th>
<th width="122" bgcolor="#E2F4F6" scope="col">发布所用账号</th>
<th width="346" bgcolor="#E2F4F6" scope="col">标题</th>
<th width="192" bgcolor="#E2F4F6" scope="col">时间</th>
<th width="144" bgcolor="#E2F4F6" scope="col">昵称</th>
<th width="77" bgcolor="#E2F4F6" scope="col">评论数</th>
<th width="71" bgcolor="#E2F4F6" scope="col">删除</th>
</tr>
<?php do
{
?>
<tr>
<th height="49" scope="col"><?php echo $commentcount=$result2['id'];?></th>
<th scope="col"><?php echo $result2['zhanghao'];?></th>
<th scope="col"><a href="view.php?id=<?php echo $result2['id'];?>">
<?php echo $result2['title'];?> </a></th>
<th scope="col"><?php echo date("Y-m-d H:i:s",strtotime($result2['time']));?></th>
<th scope="col"><?php echo $result2['name'];?></th>
<th scope="col"> <?php $sql2="select count(*) as abc from tbcomment where id='$commentcount'";
$sqlquery=mysql_query($sql2,$mylink);
$result4=mysql_fetch_array($sqlquery);
echo $result4['abc'];
?></th>
<th scope="col"><a href="shanchu.php?id=<?php echo $result2['id'];?>"><?php
echo "删除";?></a></th>
</tr><?php
}
while($result2=mysql_fetch_array($result))
?>
</table>
</div><?php
}
?>
但我在22行加上一个do {}while()想统计搜索结果总数的时候.....表格中的搜索结果内容就显示不正常了...但搜索结果总数还是显示正常
贴上错误的代码
<form name="form1" method="get" action="search.php">
<label for="title"></label>
<div align="center">
标题
<input type="text" name="title" id="title">
<input type="submit" name="submit" id="button" value="搜索">
</div>
</form>
<div align="center">
<?php
header("Content-Type:text/html;charset=utf-8");
include("conn.php");
$biaoti=$_GET['title'];
$biaoti2="%".$biaoti."%";
$sql="select * from news where title like '$biaoti2'";
$result=mysql_query($sql,$mylink);
$result2=mysql_fetch_array($result);
$i=0;
do
{
$i++;
}
while($result2=mysql_fetch_array($result));
echo "搜索内容:".$biaoti;
echo "</br>";
echo "搜索结果总数:".$i;
if($biaoti=="")
{
echo "模块初始化已完成";
}
else
{
?>
<table width="1079" height="102" border="1">
<tr>
<th width="81" height="45" bgcolor="#E2F4F6" scope="col">序号</th>
<th width="122" bgcolor="#E2F4F6" scope="col">发布所用账号</th>
<th width="346" bgcolor="#E2F4F6" scope="col">标题</th>
<th width="192" bgcolor="#E2F4F6" scope="col">时间</th>
<th width="144" bgcolor="#E2F4F6" scope="col">昵称</th>
<th width="77" bgcolor="#E2F4F6" scope="col">评论数</th>
<th width="71" bgcolor="#E2F4F6" scope="col">删除</th>
</tr>
<?php do
{
?>
<tr>
<th height="49" scope="col"><?php echo $commentcount=$result2['id'];?></th>
<th scope="col"><?php echo $result2['zhanghao'];?></th>
<th scope="col"><a href="view.php?id=<?php echo $result2['id'];?>">
<?php echo $result2['title'];?> </a></th>
<th scope="col"><?php echo date("Y-m-d H:i:s",strtotime($result2['time']));?></th>
<th scope="col"><?php echo $result2['name'];?></th>
<th scope="col"> <?php $sql2="select count(*) as abc from tbcomment where id='$commentcount'";
$sqlquery=mysql_query($sql2,$mylink);
$result4=mysql_fetch_array($sqlquery);
echo $result4['abc'];
?></th>
<th scope="col"><a href="shanchu.php?id=<?php echo $result2['id'];?>"><?php
echo "删除";?></a></th>
</tr><?php
}
while($result2=mysql_fetch_array($result))
?>
</table>
</div><?php
}
?>
$result=mysql_query($sql,$mylink);
$result2=mysql_fetch_array($result);
$i=0;
do
{
$i++;
}
while($result2=mysql_fetch_array($result));这是干什么?
echo "搜索内容:".$biaoti;
echo "</br>";
echo "搜索结果总数:".$i;
if($biaoti=="")
{
echo "模块初始化已完成";
}
else
{
?>
与php无干,略去
<?php do
{
?>
与php无干,略去
<th scope="col"><?php echo date("Y-m-d H:i:s",strtotime($result2['time']));?>$result2已在前面的 do while 中置空了,下同
</th>
<th scope="col"><?php echo $result2['name'];?></th>
<th scope="col"> <?php $sql2="select count(*) as abc from tbcomment where id='$commentcount'";
$sqlquery=mysql_query($sql2,$mylink);
$result4=mysql_fetch_array($sqlquery);
echo $result4['abc'];
?></th>
<th scope="col"><a href="shanchu.php?id=<?php echo $result2['id'];?>"><?php
echo "删除";?></a></th>
</tr><?php
}
while($result2=mysql_fetch_array($result)) $result是空的如何循环?
问题就出现在这..谢谢了..之前一直没考虑过循环后置空