PHP Classes

AED: Add, List, Edit and Delete records in MySQL tables

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 225 This week: 1All time: 8,209 This week: 560Up
Version License PHP version Categories
aed 1.0.0Freely Distributable5HTML, PHP 5, Databases
Description 

Author

This package can 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.

The listing may have links that trigger actions to add, edit, and delete records of the given table.

Picture of Vishv Sahdev
  Performance   Level  
Name: Vishv Sahdev <contact>
Classes: 13 packages by
Country: India India
Age: 52
All time rank: 51530 in India India
Week rank: 109 Up9 in India India Up
Innovation award
Innovation award
Nominee: 7x

Example

<?php
/**
 * PHP ADD EDIT DELETE EXAMPLE
 * @author admin@v23.in - http://v23.in
 * @version 1.0.0
 * @date October 21, 2015
*/

require "aed-class.php";
require
"aed-pager-class.php";
require
"aed-config.php";
// chage only aed-config.php file --------------------------------------------
//-------------- no need to change -------------------------------------------
$db = new aed(DB_HOST, DB_USER, DB_PASS, DB_NAME);


// page = PAGE NUmBER Default value page = 1;

if(isset($_GET['page']))
$page = $_GET['page'];
else
$page = 1;

if(empty(
$page) || $page < 1)
$page = 1;

// LIMIT 1, perPage Display
$start=($page - 1) * $perPageDiaplay;
$totalRow = $db->totalPage($table);

// Filename, Page =p , total Row, Current Page Value - Default 1, Per Page Display - Default 12
//$output['pager']=pager("$filename?","page=",$totalRow,$page,$perPageDiaplay);
$output['pager'] = "";
if(
$totalRow > 0){
$pager = new pager($filename,$totalRow,$page,$perPageDiaplay);
$output['pager'] = $pager->DisplayCenter();
}

$ar = $db->makeTTArray($table);
$error="Welcome!";
if(isset(
$_POST['Action']) && isset($_GET['ip']) && ($_POST['Action'] == $_GET['ip'])){
    foreach(
$ar as $k=>$v){
    if(isset(
$_POST[$k]))
   
$arr[$k]=$_POST[$k];
   
    }

        if(isset(
$_POST['route']) && ($_POST['route'] == "add" || $_POST['route'] == "Create") ){
       
$error=$db->check($table,$arr);
        if(!
$error)
       
$error = $db->insert($table,$arr);
        }
        elseif(isset(
$_POST['route']) && $_POST['route'] == "edit"){
       
$error = $db->update($table,$arr,"`$primeryKEY`=".$_POST['CusID']." LIMIT 1");
        }
        elseif(isset(
$_POST['route']) && $_POST['route'] == "del"){
       
$error = $db->delete($table,"`$primeryKEY`=".$_POST['CusID']." LIMIT 1");
        }
}
$output['error']='<p class="bg-info">'.$error.'</p>';
if(isset(
$_GET['c']) && isset($_GET['id'])){
$cc=$_GET['c'];
$id=$_GET['id'];
$ar = $db->query2row("SELECT * from $table where $primeryKEY = $id LIMIT 1");
}
else{
$cc="Create";
$id=0;
}

if(
$fieldRequire == 'ALL'){
$output['foo']=$ar;
unset(
$output['foo'][$primeryKEY]);
}
else
{
$o=explode(",",$fieldRequire);
$output['foo']=array_flip($ar);
}

$output['page']=$page;
$output['timeid'] = microtime(true);
$output['filename']=$filename;
$output['cc']=$cc;
$output['id']=$id;
$output['row']=$ar;

$field = implode(", ", array_keys($output['foo']));

$sql="SELECT $primeryKEY, $field from $table ORDER BY $primeryKEY DESC LIMIT ".$start.",".$perPageDiaplay;

$row=$db->query($sql);
if(
$row->num_rows > 0){
while(
$result = $row->fetch_assoc()){
$result['command']="<a href='$filename?id=".$result[$primeryKEY]."&c=add&page=$page'><span class=\"glyphicon glyphicon-check\" aria-hidden=\"true\"></span></a> <a href='$filename?id=".$result[$primeryKEY]."&c=edit&page=$page'><span class=\"glyphicon glyphicon-edit\" aria-hidden=\"true\"></span></a> <a href='$filename?id=".$result[$primeryKEY]."&c=del&page=$page'><span class=\"glyphicon glyphicon-trash\" aria-hidden=\"true\"></span></a> ";
$output['row'][]=$result;
}


}
else
$output['row']=array();
echo
render_temp("aed-template.htm",$output);
$db->close();
?>


  Files folder image Files  
File Role Description
Plain text file aed-class.php Class AED Class File
Plain text file aed-config.php Conf. AED Config File
Plain text file aed-example.php Example Example File
Plain text file aed-pager-class.php Class AED Pagination File
Plain text file aed-template.htm Aux. aed-Template
Plain text file aed.sql Data SQL File

 Version Control Unique User Downloads Download Rankings  
 0%
Total:225
This week:1
All time:8,209
This week:560Up