|  |  | 
|  |  |  |  | 
 
			|  |  	|  |  |  페이징 |  | 
 
				| 웹프로그램을 작성하는데 있어 가장 많이 사용하는 것이 바로 페이징 라이브러리입니다. 또한 구현하는 개발자에 따라 성능 및 형식이다양합니다. 아사달 통합솔루션인아사프로는 동 일한  페이징 라이브러리를 사용하여 UI의 일관성을 유지합니다.
 
 |  |  	| 
  페이징 라이브러리를 인클루드(include)하기 |  	| 
					| include "/home/AsaProgram/library/php/class.paging.php"; |  
 |  	|  페이징 라이브러리를 인클루드(include)하기 |  	| 
					| $page = 2;             // 현페이지 $totalRecode = 50;     // 총 글수
 $onePageNum = 10;      // 한 페이지 목록수
 $onePageLink = 20;     // 하단 링크수
 $linkPage = $PHP_SELF; // 링크페이지
 $param = "";           // 추가 파라미터
 $search_yn = "n";      // 검색여부
 $search_param = "";    // 검색 해제할 때 링크 참조값
 $paging = new Paging();
 $paging->Link($page, $totalRecode, $onePageNum, $onePageLink, $linkPage, $param, $search_yn, $search_param);
 |  |  	| 
  실제 활용 예제 |  	| 
					| <? include "/home/AsaProgram/library/php/class.db.php";
 include "/home/AsaProgram/library/php/class.paging.php';
 $db = new DBMysql($hostname, $username, $password, $dbname);
 /*
 총 글수구하기
 */
 $sql = 'select count(*) as cnt from TABLE';
 $db->setQuery($sql);
 $row_t = mysql_fetch_array($db->exQuery());
 $totalRows = $row_t[cnt];
 if (! $limit_num) $limit_num = 10;
 if (! $page ) $page = 1;
 /*
 한 페이지에 보여줄 데이터 가져오기
 */
 $sql = 'select * from TABLE order by num desc limit '.(($page-1)*$limit_num).', '.$limit_num.'';
 $db->setQuery($sql);
 $result = $db->exQuery();
 $cnt = mysql_num_rows($result);
 $pageCountScale = 10;
 $total_page = floor(($totalRows - 1) / $limit_num);
 ?>
 <table border="1" cellpadding="4" cellspacing="0" bordercolorlight="" bordercolordark="#FFFFFF" width="70%">
 <tr bgcolor="#F6F6F0">
 <td width="34" align="center">번호</td>
 <td align="center">년</td>
 <td align="center">월</td>
 <td align="center">일</td>
 <td align="center">글쓴이</td>
 <td align="center">제목</td>
 <td width="35" align="center">관리</td></tr>
 <?
 $buf = $totalRows - $limit_num * ($page - 1);
 for ($i = 0; $i != $cnt; ++$i) {
 mysql_data_seek($result, $i);
 $row = mysql_fetch_array($result);
 list ($year, $month, $day) = split('-', $row[regdate]);
 (row[writer]) == '') ? $writer = '없음' : $writer = $row[writer];
 echo '
 <tr>
 <td align="center">'.$buf--.'</td>
 <td align="center">'.$year.'</a></td>
 <td align="center">'.$month.'</a></td>
 <td align="center">'.$day.'</td>
 <td align="center">'.$writer.'</td>
 <td align="left">  '.$row[subject].'</td>
 <td align="center"><a href="./manage.htm?num='.$row[num].'">관리</a></td></tr>';
 }
 ?>
 </table>
 <table border="0" width="70%">
 <tr>
 <td>
 <?
 // 한 페이지에 보여지는 목록수
 $link = $limit_num;
 // 한 페이지에 보여지는 페이지 링크수
 $linking = $pageCountScale;
 // 전체 글수
 $record = $totalRows;
 // 링크걸릴 페이지
 $url_file = $PHP_SELF;
 // 링크시 참조값
 $url_parameter = '';
 // 검색여부
 $search_chk = ($search) ? "y" : "n";
 // 검색해제할 때 링크시 참조값
 $search_parameter = "page=1&limit_num=$limit_num";
 $paging = new Paging();
 $paging->Link($page, $record, $link, $linking, $url_file, $url_parameter, $search_chk, $search_parameter);
 ?></td></tr>
 </table>
 
 |  |  
 
 |  |   |