>백엔드 개발 >PHP 튜토리얼 >文章推荐系统(三)_PHP教程

文章推荐系统(三)_PHP教程

WBOY
WBOY원래의
2016-07-21 16:06:251187검색

=====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      for($i=0;$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      $lesssign=1;
    }
  echo"

";
   $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"";
      $lessnum++;
         if($iscolor==0){
         $color=ffffff;
         $iscolor=1;
       }
       else{
         $color=e9eae9;
         $iscolor=0;
       }
      }
       if($lesssign==1){
      for($iless=$lessnum;$iless       echo"";
          if($iscolor==0){
         $color=ffffff;
         $iscolor=1;
       }
       else{
         $color=e9eae9;
         $iscolor=0;
       }
       }
    }
  echo"
";
       echo $fuhao;
      echo"";
      $obj=mysql_fetch_object($result);
      echo $obj->articlename;
      echo"
";
       echo $fuhao."
n";
       echo"
";
  ?>
   
  
    
  
   echo"";
    $str="共有";
    $str=$str.strval($pagec);
    $str=$str."页";
    echo"";
    echo"";
    echo"";
    echo"";
    echo"
$str";
    echo"
";
    $str="当前页是第";
    $str=$str.strval($pagenum);
    $str=$str."页";
    echo $str;
    echo"
";
    echo"转到第";
    for($i=1;$i      $strpage=" ";
      $strpage=$strpage.strval($i);
      $strpage=$strpage." ";
       echo"$strpage";
    }
    echo"页";
    echo"
";
    mysql_close($conn);
  ?>

                                                      (待续)  

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/315373.htmlTechArticle=====Article.php==== ? if(!isset($pagenum)){ $pagenum=1;} $conn=mysql_connect(localhost,user,password); mysql_select_db(bamboo); $sql=select count(*) from article; $result=mysql_que...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.