ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [php]게시판 리스트 부분
    프로그램/php 2013. 7. 21. 17:18
    글 쿼리부분
    // db 객체 생성
    $db = new MysqlClass;
    
    // 검색어 찾기
    $shTitle  = ($_GET['shTitle']) ? $_GET['shTitle'] : $_POST['shTitle'];
    $shKey   = ($_GET['shKey']) ? $_GET['shKey'] : $_POST['shKey'];
    $searchQue  = "where 1 ";
    $searchQue  .= ($shTitle && $shKey) ? "  and ".$shTitle." like '%".$shKey."%' " : NULL;
    $sortQue  =" order by ref desc, seq asc";
    
    // 스타트 찾기
    $start   = ($_GET['start']) ? $_GET['start'] : $_POST['start'];
    if(!$start) $start = 0;
    
    // 한패이지에 보여질 사이즈
    $boardScale  = 10;
    // 한번에 보여줄
    $blockScale  = 5;
    
    // 게시판 정보 수집
    $listQuery  = "SELECT * FROM ".$table_Code." ".$searchQue."".$sortQue." LIMIT ".$start.", ".$boardScale;
    $countQuery  = "select count(seq) as cnt from qna";
    
    //if($_SESSION["adminMode"]["id"] != ""){ echo $listQuery; }
    $countData  = $db->fetchAll($countQuery); //전체 총 글수
    $listData  = $db->fetchAll($listQuery);
    $listDataCnt = sizeof($listData);
    $allCount  = $countData[0]["cnt"];
    $realTotal  = $db->totalCount("".$table_Code."",$searchQue);
    $staticNum  = $realTotal - $boardScale*(ceil($start/$boardScale));
    
    페이징 부분
     $boardScale){
    $page  =  floor($start/($boardScale*$blockScale)) ;
    $tmpPrev = $start - $boardScale;
    $tmpNext = $start + $boardScale;
    
    $firstBtn = "
         
         ";
    if($start+1 > ($boardScale*$blockScale)){
      $preStart = $start - $boardScale*$blockScale;
      $prevBtn = "
          
          ";
    }else {
      $prevBtn = "";
    }
    
    for($i=0; $i < $blockScale ; $i++){
      $tmpStart = ($page * $blockScale + $i)*$boardScale ;
      $thisPage= $page * $blockScale + $i+1 ;
      if($tmpStart<$realTotal){
       if($tmpStart!=$start){
        $pageText .= "".$thisPage."";
       }else{
        $pageText .= "".$thisPage."\n";
       }
       if($tmpStart<$realTotal) {
        $pageText .= " ";
       }
      }
    }
    
    if ($realTotal > (($page+1)*$boardScale*$blockScale)){
      $nextStart = ($page+1)*$boardScale*$blockScale;
      $nextBtn .= "
          
          ";
    }else {
      $nextBtn .= "";
    }
    
    $endPage = (ceil($realTotal/$boardScale)-1)*$boardScale;
    $endBtn = "
        
        
        ";
    }
    
    
    ?>
    
    

    댓글

Designed by Tistory.