PHP PROJECT

README.md

Add, List, Edit and Delete

Add, List, Edit and Delete records in MySQL tables. It can connect to a MySQL database using MySQLi and generate listing of records of a database table with support to paginate the listings with a limited amount of records.

Files


NameTypeSizeLast Modified
aed-pager-class.php phpfile icon 2328 11 November 2015 10:49:52
aed-example.php phpfile icon 3163 11 November 2015 10:49:52
aed-config.php phpfile icon 462 11 November 2015 10:49:52
aed.sql sqlfile icon 263 11 November 2015 10:49:52
aed-class.php phpfile icon 2924 11 November 2015 10:49:52
aed-template.htm textfile icon 1685 11 November 2015 10:49:52

Source

  1. <?
  2. /**
  3.  * PHP AED-PAGER Class
  4.  * @author admin@v23.in - http://v23.in
  5.  * @version 1.0.0
  6.  * @date October 21, 2015
  7. */
  8. class pager{
  9. private $pag;
  10. public function __construct($filename,$totalRow,$activePage,$perPageDisplay)
  11. {
  12. $totalPage=ceil($totalRow $perPageDisplay);
  13. $lplus=0;
  14. $rplus=0;
  15. $mid="";
  16. $start="";
  17. $end="";
  18. $l=1;
  19. $p="?page=";
  20. if($activePage $totalPage || empty($activePage))
  21. $activePage=1;
  22.  $leftDisplay=4;
  23.  $rightDisplay=4;
  24.     if($activePage <= $leftDisplay){
  25.     $lplus=$leftDisplay $activePage;
  26.     $l=1;
  27.     $rightDisplay $rightDisplay $lplus;
  28.     $end="<li><a href=\"".$filename.$p.$totalPage."\" aria-label=\"Previous\"><span aria-hidden=\"true\">&raquo;</span></a></li>";
  29.     }
  30.     else{
  31.     $l=$activePage $leftDisplay;
  32.     $end="<li><a href=\"".$filename.$p.$totalPage."\" aria-label=\"Previous\"><span aria-hidden=\"true\">&raquo;</span></a></li>";
  33.     }
  34. if(($activePage $rightDisplay) >= $totalPage)
  35.     {
  36.     $rplus=($activePage $rightDisplay) - $totalPage;
  37.     $r=$totalPage;
  38.     $l=$l-$rplus;
  39.     $start="<li><a href=\"".$filename.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>";
  40. }
  41. else
  42.     {
  43.     $r=$activePage $rightDisplay;
  44.     $start="<li><a href=\"".$filename.$p."1\" aria-label=\"Previous\"><span aria-hidden=\"true\">&laquo;</span></a></li>";
  45.     }
  46. if($totalPage 10){
  47. for($i 1;$i <= $totalPage;$i++){
  48.     if($activePage == $i)
  49.     $mid .= "<li class=\"active\"><a href=\"".$filename.$p.$i."\">".$i."</a></li>";
  50.     else
  51.     $mid .= "<li><a href=\"".$filename.$p.$i."\">".$i."</a></li>";
  52. }
  53. }
  54. else
  55. {
  56. for($i $l;$i <= $r;$i++){
  57.     if($activePage == $i)
  58.     $mid .= "<li class=\"active\"><a href=\"".$filename.$p.$i."\">".$i."</a></li>";
  59.     else
  60.     $mid .= "<li><a href=\"".$filename.$p.$i."\">".$i."</a></li>";
  61. }
  62. }
  63. $this->pag $start.$mid.$end;
  64. }
  65. public function Display(){
  66. return '<nav><ul class="pagination">'.$this->pag.'</ul></nav>';
  67. }
  68. public function DisplayCenter(){
  69. return '<div class="text-center"><nav><ul class="pagination">'.$this->pag.'</ul></nav></div>';
  70. }
  71. }
  72. function render_temp($file$data = array()) {
  73.         if (file_exists($file)) {
  74.             extract($data);
  75.             ob_start();
  76.             require($file);
  77.             $output ob_get_contents();
  78.             ob_end_clean();
  79.             return $output;
  80.         } else {
  81.         return false;
  82.         }
  83.     }
  84. ?>    

Demo

You can find a demo available here: aed

Requirment

  • mySql
  • PHP >= 5.4
  • Apache Server

Contribute

  • Vishv Sahdev

Example

>>

Download