page= 두번 나오지 않도록 해결

This commit is contained in:
gnuboard
2013-02-06 17:41:33 +09:00
parent 39e42fce85
commit e6d32bcaf4
3 changed files with 24 additions and 32 deletions

View File

@ -260,11 +260,11 @@ while ($entry = $tmp->read()) {
} }
@ksort($amenu); @ksort($amenu);
$qstr = ''; $arr_query = array();
if (isset($sst)) $qstr .= '&sst='.$sst; if (isset($sst)) $arr_query[] = 'sst='.$sst;
if (isset($sod)) $qstr .= '&sod='.$sod; if (isset($sod)) $arr_query[] = 'sod='.$sod;
if (isset($sfl)) $qstr .= '&sfl='.$sfl; if (isset($sfl)) $arr_query[] = 'sfl='.$sfl;
if (isset($stx)) $qstr .= '&stx='.$stx; if (isset($stx)) $arr_query[] = 'stx='.$stx;
if (isset($page)) $qstr .= '&page='.$page; if (isset($page)) $arr_query[] = 'page='.$page;
//$qstr = 'sst=$sst&sod=$sod&sfl=$sfl&stx=$stx&page=$page'; $qstr = implode("&", $arr_query);
?> ?>

View File

@ -18,7 +18,7 @@ function get_microtime()
// 현재페이지, 총페이지수, 한페이지에 보여줄 행, URL // 현재페이지, 총페이지수, 한페이지에 보여줄 행, URL
function get_paging($write_pages, $cur_page, $total_page, $url, $add="") function get_paging($write_pages, $cur_page, $total_page, $url, $add="")
{ {
$url = preg_replace('#(&|&)?page\=[0-9]+#', '', $url); $url = preg_replace('#&page=[0-9]*(&page=)$#', '$1', $url);
$str = ''; $str = '';
if ($cur_page > 1) { if ($cur_page > 1) {
@ -748,7 +748,15 @@ function subject_sort_link($col, $query_string='', $flag='asc')
} }
} }
return '<a href="'.$_SERVER['PHP_SELF'].'?'.$query_string.'&amp;'.$q1.'&amp;'.$q2.'&amp;sfl='.$sfl.'&amp;stx='.$stx.'&amp;page='.$page.'">'; $arr_query = array();
$arr_query[] = $q1;
$arr_query[] = $q2;
$arr_query[] = 'sfl='.$sfl;
$arr_query[] = 'stx='.$stx;
$arr_query[] = 'page='.$page;
$qstr = implode("&amp;", $arr_query);
return "<a href=\"{$_SERVER['PHP_SELF']}?{$qstr}\">";
} }

View File

@ -1,24 +1,8 @@
<!doctype html> <?
<html lang="ko"> $qstr1 = "&amp;stx=ddd&amp;page=123";
<head> $qstr2 = "&amp;stx=ddd&amp;page=123&amp;";
<title>title</title> $qstr3 = "&amp;stx=ddd&amp;page=&amp;";
<meta charset="utf-8"> $qstr3 = "&amp;stx=ddd&amp;page=x&amp;";
<script src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<p> 문자열에서 부분을 치환합니다.</p> echo preg_replace('#(&amp;|&)?page\=[^&]*#', '', $qstr3);
?>
<a href="#" title="치환">치환하기</a>
<script>
$(function(){
$('a').click(function(){
$('p').text("치환");
});
});
</script>
</body>
</html>