function cut_string(&$tname,$slen)
{
if(strlen($tname) < $slen) {
return $tname ;
}
$strstr=strlen($tname) ;
$lenstr=$slen ;
for($k=0; $k<$lenstr-1; $k++) {
if(ord(substr($tname, $k, 1))>127) {
$k++ ;
}
}
if ($strstr > $lenstr) {
//$tname=substr($tname, 0, $k)."¢â" ; //À߸°¹®ÀÚ¿ µÚ¿¡ ¢âÀ» ºÙÀÔ´Ï´Ù..
$tname=substr($tname, 0, $k).".." ; //À߸°¹®ÀÚ¿ µÚ¿¡ ¢âÀ» ºÙÀÔ´Ï´Ù..
}
else {
$tname=$tname ;
}
return $tname ;
}
include "./connect.inc" ;
$eventdb= DB::connect($dsn['event'],true) ;
if(DB::isError($eventdb))
{
die($eventdb->getMessage()) ;
}
$query = "select count(*) from dongyang_event " ;
$total = $eventdb->getOne($query) ;
$max_row = 10 ;
$max_scale = 20 ;
$tpage = ceil($total/$max_row) ;
$lpage_row = $total % $max_row ;
// ÆäÀÌÁö¹øÈ£°¡ ¸Â´ÂÁö °Ë»ç
if ($cpage < 1) $cpage = 1 ;
if ($cpage > $tpage) $cpage = $tpage ;
$ppage = $cpage-1 ;
$npage = $cpage+1 ;
$seek = $ppage * $max_row ;
$cscale = intval($cpage/$max_scale) ;
if ( !($cpage%$max_scale) ) $cscale-- ;
$tscale = intval($tpage/$max_scale) ;
$lscale_no = $tpage % $max_scale ;
if ($lscale_no == 0) $tscale-- ;
$pscale_page = $cscale * $max_scale ;
$nscale_page = $cscale * $max_scale + $max_scale + 1 ;
?>
µ¿¾çÁ¾ÇÕ±ÝÀ¶Áõ±Ç
|
|
|
|
$query = "select * from dongyang_event order by idx desc limit $seek,$max_row" ;
$result = $eventdb->query($query) ;
if(DB::isError($result))
{
die($result->getMessage()) ;
}
$i = 0 ;
while($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
$no = $total-($seek+$i) ;
//$comment = cut_string($row[comment],50) ;
$comment = $row[comment] ;
echo "
$no |
$row[name] |
$row[regdate] |
|
$comment |
|
|
" ;
$i++ ;
}
?>
if ($cpage > $max_scale) {
echo "óÀ½" ;
echo " ÀÌÀü " ;
}
else {
echo "" ; // ÀÌÀü¾øÀ½
}
$ss = $pscale_page + 1; // $ss = È¸é ¹Ø¿¡ Ç¥½ÃÇÒ ½ÃÀÛ ÆäÀÌÁö ±¸Çϱâ
if ( ($cscale>=$tscale) && ($lscale_no!=0) ) $se = $ss + $lscale_no;
else if ($cscale <= -1) $se = $ss;
else $se = $ss + $max_scale;
for($j=$ss; $j<$se; $j++)
{
if ($j==$cpage) { //ÇöÀç ÆäÀÌÁö
echo " $j " ;
} else {
echo " $j " ;
}
}
if($tpage >= $nscale_page) {
echo " ´ÙÀ½" ; // ´ÙÀ½10°³
//¸¶Áö¸· ÆäÀÌÁö
echo " ¸¶Áö¸·" ; // ¸ÇµÚ·Î
}
else {
echo "" ; // ´ÙÀ½¾øÀ½
}
?>
|
|
|
|
|
|
|