单位要做新闻类的
web网站,如何在设定好的工作动态表格或表单中实现7个
文件链接,有参考代码,怎么修改代码,谢谢。只要从
mysql库中调用“工作动态”分类中的7个文件链接,如果单击某个新闻标题链接,则进入相应的新闻浏览页。新发布的新闻会后来居上,超过7个,则下方的新闻标题被挤出。
如图
[attach]522[/attach]
可以参考的代码
引用:
<!--工作动态-->
<tr>
<td width="410" height="33" background="images/GNewtop.gif" bgcolor="#ffffff"><div align="justify"><span class="xxcx"> ◎工作动态</span></div></td>
</tr>
<td height="257" valign="top">
<?php
mysql_data_seek ( $rsCategory, 0 );
$row_rsCategory = mysql_fetch_assoc($rsCategory);
do {
// 创建记录集rsNews
$sql2 = sprintf ( "SELECT * FROM newsinfo WHERE CategoryID=%d ORDER BY IssueTime DESC LIMIT 8",
$row_rsCategory['CategoryID'] );
$rsNews = mysql_query ( $sql2 ) or die ( mysql_error() );
$row_rsNews = mysql_fetch_assoc ( $rsNews );
$totalRows_rsNews = mysql_num_rows ( $rsNews );
if ( $totalRows_rsNews > 0 ) {
printf ( "<table align=\"center\" border=\"0\" width=\"96%%\" rules=\"none\">\n" );
printf ( "<tr bgcolor=\"#cccccc\">" );
printf ( "<td align=\"center\">%s</th>\n", $row_rsCategory['CategoryName'] );
printf ( "<td align=\"center\"><a href=\"classify.php?cid=%d&cname=%s\">更多%s...</a></td>\n",
$row_rsCategory['CategoryID'],
urlencode ( $row_rsCategory['CategoryName'] ),
$row_rsCategory['CategoryName'] );
do {
printf ( "<tr>\n" );
printf ( "<td colspan=\"2\">" );
printf ( " ·<a href=\"shownews.php?nid=%d&cname=%s\" target=\"_blank\">%s</a>",
$row_rsNews["NewsID"],
urlencode ( $row_rsCategory['CategoryName'] ),
$row_rsNews["Title"] );
printf ( "<font color=\"#aaaaaa\">(%s)</font></td>", $row_rsNews["IssueTime"] );
printf ( "</tr>\n" );
} while ( $row_rsNews = mysql_fetch_assoc ( $rsNews ) );
printf ( "</table>\n" );
} else {
continue;
}
} while ($row_rsCategory = mysql_fetch_assoc($rsCategory));
?>
</p>
[
本帖最后由 kakamaomao 于 2008-3-9 11:48 编辑 ]