Ec (2); pdo paging & lt ;? Php $ page $ _ GET [page]; $ dsn & quot; mysql: hostlocalhost; dbnamebbv1 & quot; $ db & nbsp; newPDO ($ dsn, root,); & nbsp; pdo link $ num10; & script ec (2); script
Pdo Paging
$ Page = $ _ GET ['page'];
$ Dsn = "mysql: host = localhost; dbname = bbv1 ";
$ Db = new PDO ($ dsn, 'root', ''); // pdo Link
$ Num = 10; // number of articles displayed on each page
$ Pagea = ($ page-1) * $ num;
Foreach ($ db-> query ("SELECT * from article Limit $ pagea, $ num") as $ row)
{
Echo "";
Print_r ("delete ");
Print_r ($ row [1]);
Print_r ($ row [2]);
Print_r ($ row [3]);
}
$ Rs = $ db-> query ("select COUNT (*) from article"); // get the total number of data
$ Count = $ rs-> fetchColumn ();
$ Pagenum = ceil ($ count/$ num );
?>
Add article
Total number of articles:
Total Article Page:
For ($ I = 1; $ I <= $ pagenum; $ I ++ ){
$ Show = ($ I! = $ Page )? "$ I ":"$ I";
Echo $ show ."";
}
$ Db = null;
?>