js 端 及判断1?now-1:1;
break
;
case
'next':
target=now+1>allpage?now:1;
break
;
case
'last':
target=allpage>0?allpage:1;
break
;
case
'constans':
target=$('#selpage').val()>0?$('#selpage').val():1;
default
:
target=1;
}
var
data=
"check="
+act+
"&nowpage="
+now+
"&perpage="
+per+'&target='+target;
alert(data);
return
data;
}
function
goPageFirst()
{
var
param=getData('first');
http_post(param);
}
function
goPagePrev()
{
var
param=getData('prev');
http_post(param);
}
function
goPageNext()
{
var
param=getData('next');
http_post(param);
}
function
goPageLast()
{
var
param=getData('last');
http_post(param);
}
function
goPage()
{
var
param=getData('constans');
http_post(param);
}
function
http_post(db)
{
$.post('./mysql.php',db,
function
(data){
responseAjax(data);
},'text');
}
function
responseAjax(msg)
{
$('#listDiv').html(msg);
}
server端 判断及实现
mb_internal_encoding('gb2312');
$con
=mysql_connect(
"127.0.0.1"
,
"root"
,
"12345678"
)
or
die
(
"连接失败"
);
$m
=mysql_select_db(
"ec"
,
$con
);
$sql
= 'SELECT `attr_id`,`cat_id`,`attr_name`
FROM `ecs_attribute` ';
$rs
= mysql_query(
$sql
);
$count
= mysql_num_rows(
$rs
);
if
(!isset(
$_POST
['check']))
{
$set
['id']=0;
die
('no access please!');
}
if
(isset(
$_POST
['perpage']) &&
$_POST
['perpage']>0 )
{
$per
=
$_POST
['perpage'];
}
else
{
$per
=15;
}
$page
=
ceil
(
$count
/
$per
);
if
(!isset(
$_POST
['nowpage']))
{
$nowPage
=1;
}
else
{
$nowPage
=
$_POST
['nowpage'];
}
$start
= (
$nowPage
-1)*
$per
+1;
$sql
= 'select `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit '.
$start
.','.
$per
;
$rs
= mysql_query(
$sql
);
$str
=
"属性编号类型编号属性名字"
;
while
(
$row
= mysql_fetch_assoc(
$rs
)){
$str
.=''.
$row
['attr_id'].''.
$row
['cat_id'].''.
$row
['attr_name'].'';
}
$str
.=
"总计"
.
$count
.
"个记录分为"
.
$page
.
"页当前第"
.
$nowPage
.
"页,每页 | 第一页 上一页 下一页 最末页 "
;
for
(
$i
=1;
$i
".$i."
";
}
else
{
$str
.=
""
.
$i
.
""
;
}
}
$str
.=
""
;
echo
mb_convert_encoding(
$str
,'UTF-8','gb2312');
?>
.code_report{float:right}
.code_report p{ float: left; margin-left: 5px; background: url(
"/img/ask-icon.gif"
) no-repeat; padding: 6px 0 6px 15px; padding-left: 15px; height: 16px;}
.code_report a{ background: url(
"/img/ask-icon.gif"
) 0 -160px no-repeat;padding-left: 20px; line-height: 15px;height: 16px; color: #333; text-decoration: none; display:inline-block; zoom:1; vertical-align: middle;}
.code_report em{ height: 28px; line-height:28px; width: 14px; display: inline-block; float: left; background: url(
"/img/ask-icon.gif"
) top right;}
" _ue_custom_node_="
true">