复制代码 代码如下:class mysql{
function connect($dbhost, $dbuser, $dbpw, $dbname = '',$dbcharset='') {
if(!@mysql_connect($dbhost, $dbuser, $dbpw)) {
$this->show('Can not connect to MySQL server');
}
if($dbname) {
$this->select_db($dbname);
}
if($this->version() > '4.1') {
if($dbcharset) {
$this->query("SET NAMES '".$dbcharset."'");
}
}
}
function select_db($dbname) {
return mysql_select_db($dbname);
}
function fetch_array($query, $result_type = MYSQL_ASSOC) {
return @mysql_fetch_array($query, $result_type);
}
function query($sql, $type = '') {
if(!($query = mysql_query($sql))) $this->show('MySQL Query Error', $sql);
return $query;
}
function affected_rows() {
return mysql_affected_rows();
}
function result($query, $row) {
return mysql_result($query, $row);
}
function num_rows($query) {
return @mysql_num_rows($query);
}
function num_fields($query) {
return mysql_num_fields($query);
}
function free_result($query) {
return mysql_free_result($query);
}
function insert_id() {
return mysql_insert_id();
}
function fetch_row($query) {
return mysql_fetch_row($query);
}
function version() {
return mysql_get_server_info();
}
function close() {
return mysql_close();
}
function show($message = '', $sql = '') {
if(!$sql) echo $message;
else echo $message.'<br>'.$sql;
}
}
class page extends mysql{
function pagination($sql,$maxnum,$page,$maxpages,$pagepre,$ext=''){
global $sum,$stail,$link,$lmid,$ltail,$curpage;//$ext='&class=3'
$SELF = $_SERVER['PHP_SELF'];
$query = $this->query($sql);
$rows = $this->fetch_array($query,MYSQL_NUM);
$totalrows = $rows[0];
$totalpages = ceil($totalrows/$maxnum);
$startnum = ($page - 1)*$maxnum;
$string = $sum.$totalrows.$stail.$sum.$page."/".$totalpages.$stail;
if($page != 1){
$string .= $link.$SELF."?page=1".$ext.$lmid."|‹".$ltail;
$string .= $link.$SELF.'?page='.($page - 1).$ext.$lmid."‹‹".$ltail;
}
if($maxpages>=$totalpages){
$pgstart = 1;$pgend = $totalpages;
}
elseif(($page-$pagepre-1+$maxpages)>$totalpages){
$pgstart = $totalpages - $maxpages + 1;
$pgend = $totalpages;
}
else{
$pgstart=(($page<=$pagepre)?1:($page-$pagepre));
$pgend=(($pgstart==1)?$maxpages:($pgstart+$maxpages-1));
}
for($pg=$pgstart;$pg<=$pgend;$pg++){
if($pg == $page){
$string .= $curpage.$SELF."?page=".$pg.$ext.$lmid.$pg.$ltail;
}
else $string .= $link.$SELF."?page=".$pg.$ext.$lmid.$pg.$ltail;
}
if($page != $totalpages){
$string .= $link.$SELF.'?page='.($page + 1).$ext.$lmid."››".$ltail;
$string .= $link.$SELF.'?page='.$totalpages.$ext.$lmid."›|".$ltail;
}
return $string;
}
}
function html($str){
$str = get_magic_quotes_gpc()?$str:addslashes($str);
return $str;
}
function dehtml($str){
$str = nl2br(stripslashes($str));
return $str;
}
function deip($str){
$arr = explode('.',$str);
$str = $arr[0].'.'.$arr[1].'.'.$arr[2].'.*';
return $str;
}
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 黑鸭子2005-紫丁香[首版][WAV+CUE]
- 林忆莲《爱上一个不回家的人》XRCD版[低速原抓WAV+CUE][999M]
- 经典《历届奥斯卡金曲回顾》[正版原抓WAV+CUE] [1G]
- 群星《试音草原·女声篇》经典蒙古民歌[WAV+CUE][1G]
- 炉石传说月末上分卡组推荐 国服月末最快上分卡组推荐
- 炉石传说月底最强卡组有哪些 2024国服月底最强卡组推荐
- 炉石传说月初最强卡组有哪些 2024月初最强上分卡组推荐
- 狼人杀亮相原生鸿蒙之夜 假面科技强势登陆华为生态
- 12小时光线挑战!AI画质专家才是大平层首选
- 2024游戏IP报告:1~9月规模1960亿 68%用户愿为之付费
- 群星.2024-今夜一起为爱鼓掌电视剧原声带【相信音乐】【FLAC分轨】
- BIGFOUR.2013-大家利事【寰亚】【WAV+CUE】
- 李美凤.1992-情深透全情歌集【EMI百代】【WAV+CUE】
- 田震2024-《时光音乐会》[金峰][WAV+CUE]
- 群星《监听天碟3》[LECD]限量版[WAV+CUE]