结尾处:
<?php include('foot.php')?>
</div>
</body>
<?php
}
?>
=》
<?php
}
?>
<?php include('foot.php')?>
</div>
</body>
未测试效果,目的是你把foot放在你的while{}外面。
<?php include('foot.php')?>
</div>
</body>
<?php
}
?>
=》
<?php
}
?>
<?php include('foot.php')?>
</div>
</body>
未测试效果,目的是你把foot放在你的while{}外面。
echo "抱歉,此栏目暂时没有文章!";
include('foot.php');
exit(0);
}else{
//你要执行的代码!}
http://topic.csdn.net/u/20081208/11/aac0973f-b376-42e5-84bd-8400aa8dc4f0.html依照你的代码,
回避是用die函数,判断$conn1的有无就可以了。$conn1=mysql_query($sql);
if($conn1){
while($rs=mysql_fetch_array($conn1)){
?>
</td>
</tr>
<tr bgcolor="">
<td width="8%" align="center" style="font-size: 14; height: 20px;">
<div align="center"><?=$i++?></div></td>
<td width="57%" style="font-size: 14; height: 20px;"><div id="textcontent"><a href="show.aspx?id=<?=$rs[wyx_id]?>" target="_blank"><?=sub_str($rs[wyx_title],35,true)?></a></div>
</td>
<td width="20%" align="right" style="font-size: 14; height: 20px;"><div align="center" style="text-align: center"><?=substr($rs[wyx_date],0,10)?></div></td>
<td width="15%" align="right" style="font-size: 14; height: 20px;"><div align="center" style="text-align: center"><?=$rs[wyx_hits]?></div></td>
</tr>
<?php
}
}else{
// 舒出相应的HTML
echo "抱歉,此栏目暂时没有文章!"
}
别学金鱼,给啥吃啥
出错了吧,你看看http://www.wyxuan.com/list.php?id=2
我自己加了啊,不知错在哪里...<?php
}
}else{
echo "抱歉,此栏目暂时没有文章!";
?>
不知道能不能理解我的本意,
lz先把这句代码理解了再说吧
$conn1=mysql_query($sql) or die ('抱歉,此栏目暂时没有文章!');
if($conn1=mysql_query($sql))
{
while($rs=mysql_fetch_array($conn1)){
?>
</td>
</tr>
<tr bgcolor="">
<td width="8%" align="center" style="font-size: 14; height: 20px;">
<div align="center"><?=$i++?></div></td>
<td width="57%" style="font-size: 14; height: 20px;"><div id="textcontent"><a href="show.aspx?id=<?=$rs[wyx_id]?>" target="_blank"><?=sub_str($rs[wyx_title],35,true)?></a></div>
</td>
<td width="20%" align="right" style="font-size: 14; height: 20px;"><div align="center" style="text-align: center"><?=substr($rs[wyx_date],0,10)?></div></td>
<td width="15%" align="right" style="font-size: 14; height: 20px;"><div align="center" style="text-align: center"><?=$rs[wyx_hits]?></div></td>
</tr>
<?php
}
?>
</table>
<br />
<div id="wyxcontent">共有 <span class="wzw2"><? echo $sum3[0];?></span> 篇文章,每页显示 <span class="wzw2">20</span> 篇文章<br/>
<a href='?id=<?=$id?>&page=1'>首 页</a>
<?php
if($page>1)
echo "<a href='?id=$id&page=$prestart'>上一页</a>";
echo " ";if ($page>9) //找到翻页的开始
$star = $page-9;
else
$star = 1; if ($page+9>$total_page) //找到翻页的结束
$end = $total_page;
else
$end = $page+9; for($t=$star;$t <=$end;$t++)
{
if($page==$t)
{
echo " <font color='red'>[".$t."]</font> ";
}
else
{
echo " <a href='?id=$id&page=".$t."'>[".$t."]</a> ";
}
}
if($page<$total_page)
echo "<a href='?id=$id&page=$nextpage'>下一页</a>";
echo " ";
?>
<a href='?id=<?=$id?>&page=<?php echo $lastpg ?>'>尾 页</a>
</div><br/>
</div>
</div>
}
}
else
{
echo "没有这类文章!";
}
include('foot.php');
?>
</body>