当前位置: 首页 > 图文教程 > 网络编程 > PHP > 文章推荐系统(三)

PHP
mysql5的sql文件导入到mysql4的方法
sqlyog 中文乱码问题的设置方法
PHP CURL函数库
PHP 面向对象改进后的一点说明
攻克CakePHP系列一 连接MySQL数据库
CakePHP去除默认显示的标题及图标的方法
攻克CakePHP系列二 表单数据显示
攻克CakePHP系列三 表单数据增删改
smarty的保留变量问题
PHP syntax error, unexpected $end 错误的一种原因及解决
如何使用PHP编程说明
php合并数组array_merge函数运算符加号与的区别
php初学者写及时补给skype用户充话费的小程序
MySql 按时间段查询数据方法(实例说明)
Php Cookie的一个使用注意点
PHP程序61条面向对象分析设计的经验小结
令PHP初学者头疼十四条问题大总结
mysql limit查询优化分析
使用Limit参数优化MySQL查询的方法
方便实用的PHP生成静态页面类(非smarty)

PHP 中的 文章推荐系统(三)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 239 ::
收藏到网摘: n/a

=====Article.php====
<?
if(!isset($pagenum)){
$pagenum=1;}
$conn=mysql_connect("localhost","user","password");
mysql_select_db("bamboo");
$sql="select count(*) from article";
$result=mysql_query($sql,$conn);
$count=mysql_result($result,0);
$sign=0;
$lesssign=0;
$pagec=1;
for($icount=0;($icount<$count)&&($sign=0);$icount+=16){
for($i=0;$i<=16;$i++){
if(($icount*16+$i)==$count)
$sign=1;
}
$pagec++;
}
$dispeof=16*$pagenum;
$dispend=16*($pagenum-1);
if($count>=(16*$pagenum))
$dispbeg=16*$pagenum;
else
$dispbeg=$count;
$isdispnum=$count-$dispeof;
if($isdispnum<0){
$lesssign=1;
}
echo"<table width=100%>";
$fuhao="◇ ";
$color=e9eae9;
$iscolor=0;
$lessnum=0;
for($i=$dispbeg;$i>$dispend;$i--){
$sql="select *from article where id='$i'";
$result=mysql_query($sql,$conn);
echo"<tr><td align=left bgcolor=$color>";
echo $fuhao;
echo"<a href=articledisp.php?article_id=$i>";
$obj=mysql_fetch_object($result);
echo $obj->articlename;
echo"</a></td></tr>";
$lessnum++;
if($iscolor==0){
$color=ffffff;
$iscolor=1;
}
else{
$color=e9eae9;
$iscolor=0;
}
}
if($lesssign==1){
for($iless=$lessnum;$iless<=16;$iless++){
echo"<tr bgcolor=$color><td>";
echo $fuhao."<br>n";
echo"</td></tr>";
if($iscolor==0){
$color=ffffff;
$iscolor=1;
}
else{
$color=e9eae9;
$iscolor=0;
}
}
}
echo"</table>";
?>
</td>
</tr>
</table>
<?
echo"<table width=100% bgcolor=00ff00>";
$str="共有";
$str=$str.strval($pagec);
$str=$str."页";
echo"<tr><td>$str";
echo"</td>";
echo"<td align=center>";
$str="当前页是第";
$str=$str.strval($pagenum);
$str=$str."页";
echo $str;
echo"</td>";
echo"<td>";
echo"转到第";
for($i=1;$i<=$pagec;$i++){
$strpage=" ";
$strpage=$strpage.strval($i);
$strpage=$strpage." ";
echo"<a href=articlcont.php?pagenum=$i>$strpage</a>";
}
echo"页";
echo"</td>";
echo"</tr>";
echo"</table>";
mysql_close($conn);
?>
(待续)