ajaxCRUD.com
» a PHP API to create / read / update / delete from a database table using AJAX
What is AjaxCRUD?
AjaxCRUD is an open-source PHP API which allows you to connect to a mySQL database and easily
perform the necessary CRUD operations (create, read, update, & delete rows).
Please explain...
Have you ever needed to get easy access to a database table and you don't have the time to code all the necessary actions you need (add rows, edit a row, delete a row...)?
This PHP class allows you to get the access you need without spending the time and energy on lengthy coding.
Give me an Example
Consider the following table:
CREATE TABLE tblCustomer(
pkCustomerID INT PRIMARY KEY AUTO_INCREMENT,
fldFName VARCHAR(40),
fldLName VARCHAR(40),
fldPaysBy VARCHAR(20),
fldDescription TEXT
);
Now see the API work in action:
(try adding, editing (clicking on the field), or deleting a record)
Edit Customers
| First | Last | Pays By | Customer Info | Action |
|---|
Hundreds of other styles available at http://icant.co.uk/csstablegallery
(View Demo outside template)
How did you do that?
Just a few lines of code:
#the code for the class
include ('AjaxCRUD.class.php');
#this one line of code is how you implement the class
$tblCust = new AjaxCRUD("Customer", "tblCustomer", "pkCustomerID");
//don't show the primary key in the table
$tblCust->omitPrimaryKey();
// my db fields all have prefixes;
// make them display an readable titles
$tblCust->displayAs("fldFName", "First");
$tblCust->displayAs("fldLName", "Last");
$tblCust->displayAs("fldPaysBy", "Pays By");
$tblCust->displayAs("fldDescription", "Customer Info");
//text the height for my textareas (longer fields)
$tblCust->setTextareaHeight('fldDescription', 100);
# define allowable fields for my dropdown fields
# (this can also be done for a pk/fk relationship)
$values = array("Cash", "Credit Card", "Paypal");
$tblCust->defineAllowableValues("fldPaysBy", $values);
#actually show to the table
$tblCust->showTable();
Ok, I'm sold. Let me try it out!
» Download the code
» Leave a Comment
» View the API Reference Material
» View Demo outside template