ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

PHP

php ํŽ˜์ด์ง•

๐Ÿฉท ์Šˆ ๐Ÿงก 2012. 1. 14. 22:00
728x90
SMALL


<?
class Helper
{
 static function Pagination($current_page, $total_row, $page_size)
 {
  $total_page = ceil($total_row / $page_size);
  
  $start = $current_page - 5;
  if ($start < 1) $start = 1;
  
  $end = $start + 10;
  if ($end > $total_page) $end = $total_page;  
  
  $start = $end - 10;
  if ($start < 1) $start = 1;

  $pages = array();
  
  if ($start > 1) $pages[] = "<a href=\"1\" class=\"page-num\">1</a> ..";
  
  for ($i = $start; $i <= $end; $i++)
  {
   if ($i == $current_page)
   {
    $pages[] = "<a href=\"{$i}\" class=\"page-num current-page\">{$i}</a>"; 
   }
   else
   {
    $pages[] = "<a href=\"{$i}\" class=\"page-num\">{$i}</a>"; 
   }
  }
  
  if ($end < $total_page) $pages[] = ".. <a href=\"{$total_page}\" class=\"page-num\">{$total_page}</a>";
  
  return implode(' ', $pages);
 }
}
?>

728x90
LIST
๋Œ“๊ธ€
it,์Šˆ2008/2/14 Start...
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2025/04   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
๊ธ€ ๋ณด๊ด€ํ•จ
250x250