简单的分页存储过程 php mysql mysqli扩展

create database cunchu;
use cunchu;
set names gbk;
create table member(
id int(8) unsigned primary key auto_increment,
name varchar(50) not null,
email varchar(50) not null
) engine=myisam;

insert into member(name,email) values('xiaoming','[email protected]');
insert into member(name,email) values('小明','[email protected]');

//分页存储过程
 CREATE PROCEDURE  cun11(beg int,en int)
 BEGIN
  select * from member order by id desc limit beg,en; 
 END$$

//调用
<?php 

$dblink=new mysqli('localhost','root','root','cunchu');
$dblink->query('set names gbk');
if($result=$dblink->query("call cun11(1000,20)")){
 while($row=$result->fetch_array())
 {
  echo $row['id']."===========".$row['name']."-------".$row["email"].'<br/>';
 }
}
?>



 



你可能感兴趣的:(简单的分页存储过程 php mysql mysqli扩展)