/**
* 生成頁碼列表**
@author qifei*@
param int $element_total_count 元素總數*@
param int $current_page 當前頁*@
param int $per_page_elem_count 每頁元素數*@
param int $show_page_num 列表顯示的頁碼數*@
param string $up_down_class 上下翻頁樣式*@
param string $num_class 當前頁頁碼數字樣式*@
param string $href 頁面鏈結*@
param string $page_symbol 傳遞頁碼數的鏈結引數
*@return string */
function get_page_link_list(
$element_total_count,
$current_page=1,
$per_page_elem_count=10,
$show_page_num=10,
$up_down_class,
$num_class,
$href
,$page_symbol=
'p')}}
}if(
!empty(
$params_str)
)$href
= $page_name .
'?'. $params_str;
else
$href
= $page_name;
$href
= rtrim(
$href
,'&');
}$prefix = strpos(
$href
,"?")?
"&":
"?";
$prefix .
= $page_symbol;
$page_total_count = ceil(
$element_total_count/
$per_page_elem_count)
;if(intval(
$element_total_count)
< 1 |
|!isset(
$element_total_count)
)if(
$element_total_count <
= $per_page_elem_count)
return ''
;if(
$current_page>
$page_total_count)
$current_page = 1;
if(strpos(
$href
,"#"))
/* 生成頁碼 *
/if(
$current_page > ceil(
$show_page_num/2)
)else
if(!empty(
$num_class)
)$num_class_str =
' class="'
.$num_class.
'"';
else
$num_class_str ='';
$page_num_string ='';
for($i
=$start;$
i<
=$end;$i
++)/
* 上下翻頁 *
/$prev_page =
(intval(
$current_page-1)
>0)
?intval(
$current_page-1)
:0;$next_page =
(intval(
$current_page)
<
$page_total_count)
? intval(
$current_page+1)
: 0;
if(!empty(
$up_down_class)
)$up_down_class_str =
' class="'
.$up_down_class.
'"';
else
$up_down_class_str ='';
$page_up_string ='';
if(intval(
$prev_page)
> 0)
$page_up_string ='.$
href
.$prefix.
'='.
$prev_page.
$label
.'"'
.$up_down_class_str.
;else
$page_up_string =
'.$up_down_class_str.
;$page_down_string ='';
if(intval(
$next_page)
> 0)
$page_down_string .='.
$href
.$prefix.
'='.
$next_page.
$label
.'"'
.$up_down_class_str.
;else
$page_down_string .='.
$up_down_class_str.;/
* 返回結果 *
/return $page_up_string . $page_num_string . $page_down_string;
}
PHP運算元據庫 分頁鏈結生成函式
1 在前表 emp info 基礎上再新增些資料。insert into emp info e id e name e gender e dept date of birthday date of entry values 5,小蘭 女 人事部 2020 11 19 2014 4 21 17 00 ...
php mysql 短鏈結 PHP生成短鏈結案例
首先我們建立的檔案有三個,api檔案 生成短連線呼叫 index檔案 訪問短連線時跳轉使用 config檔案 連線資料庫用的 呼叫方法 網域名稱 api.php?url nginx規則 location elseelseelseelse echo json encode array code 201...
函式 匿名函式,列表生成式
lambda x x 2關鍵字lambda表示匿名函式,冒號前面的x表示函式引數。匿名函式。用法 func lambda x x 2 print func 2 4l list map lambda x x 2,range 5 map func,iterables print l 0,2,4,6,8 ...