Home > Backend Development > PHP Tutorial > PHP connection access database and modification delete add data instance_PHP tutorial

PHP connection access database and modification delete add data instance_PHP tutorial

WBOY
Release: 2016-07-13 17:05:26
Original
869 people have browsed it

php tutorial connection access database tutorial and modification delete add data instance
This article provides an example of how to use PHP to connect to the access database and modify, delete and add data. On the home page, we will tell you how to use PHP to connect to the access database and then add, modify, edit, display, delete and paginate the data source code.
*/

$conn = new com("adodb.connection");
$conn->open("driver={microsoft access driver (*.mdb)}; dbq=".db_path.";uid=;pwd=;");

$rs=new com("adodb.recordset");
$rs->open("select * from [article] order by [articleid]",$conn,1,3);
$rs->pagesize=5;
$page=trim($_get['page']);
if($page=="" || is_numeric(intval($page))<=0){$page=1;}else if(intval($page)>$rs->pagecount){$page =$rs->pagecount;}
$page=intval($page);
if(!$rs->eof||$rs->bof){
$rs->absolutepage=$page; $mypagesize=$rs->pagesize; $i=$rs->recordcount()-($page-1)*$rs->pagesize;
while(!$rs->eof && $mypagesize>0 && $i>=$rs->recordcount()-1-$rs->pagesize*$page){
$articleid = $rs->fields(0)->value;
$articletitle = $rs->fields(1)->value; ?>

  • < ? echo $articlei; ?>

  • movenext; $mypagesize--; $i--; } } ?>




    Head page Previous page next page Last page  Totalrecordcount(); ?>Articles, divided into< ? echo $rs->pagecount;?> page is displayed, now it is page