-
[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));
페이징 부분if($realTotal > $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 = " "; } ?>
=$firstBtn?> =$prevBtn?> =$pageText?> =$nextBtn?> =$endBtn?> '프로그램 > php' 카테고리의 다른 글
[php]파일업로드 부분 is_uploaded_file,upload (0) 2013.07.21 [php]메일보내기, sendMail, mail (0) 2013.07.21 [php]ip로 차단,REMOTE_ADDR (0) 2013.07.21 [php]쿠키 클래스,cookie (0) 2013.07.21 [php]MY-SQL 인코딩 변경, set name utf8 (0) 2013.07.21