来源:自学PHP网 时间:2014-12-25 09:57 作者: 阅读:次
[导读] 文章推荐系统(三),=====Article.php====lt;?if!isset$pagenum{nbsp;nbsp;nbsp;$pagenum=1;}$conn=MySQL_connectquot;localhostquot;,quot;userquot;,quot;passWordquot;;mysql_select_dbquot;bambooquot;;$sql=quot;selectcount*fromarticlequot;;$...
=====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); ?> (待续) |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com