» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX

   by loud canvas media

Quick Links:

Quick Examples:

What is ajaxCRUD?

ajaxCRUDTM is an open-source PHP class which allows you to connect to a mySQL database table and easily perform the necessary CRUD operations (create, read, update, & delete rows). Use this tool to view data in your table, add rows. edit content, and delete rows at the click of a button (and no page reloading due to ajax).

Please explain...

Ever needed to provide easy "admin" access to a database table, but don't have the time/budget to code all the necessary actions you need (inserts, updates, deletes, etc...)? This PHP class allows you (and/or your clients) to get direct access to your data with a few lines of code. Short story: save time!

"Customers" Example:

(try Adding, Editing (clicking on the field), or Deleting a record)

FirstLastPays ByPhoneZipAction
I'l editing this field Credit Card (439) 439-3403 MatJk
Storthe Storthe Credit Card PpDWRbRimwVZunz 12342
teste yh Credit Card (555) 555-4544 --
Storthe Storthe Credit Card MlgVGXeYEef gVIZD
Storthe Storthe Credit Card SJIQqPvHJXczgmR XnbJb
ahmed haj Cash (123) 456-7890 99999
Storthe Storthe Credit Card YZgWknvNduXZU BWBkz
Storthe Storthe Credit Card UiVwmOzmvZlAlUh ijebd
Storthe Storthe Credit Card dXbTLuPrGajtWAu ErazR
Storthe Storthe Credit Card PjjLwUBKUzfv FYLCm
Storthe Storthe Credit Card PLpigzbtAdVpayb ZtLXr

Please do not post web-links (urls) of any kind or you will be banned.

Hundreds of other styles available at http://icant.co.uk/csstablegallery

Okay, how did you do that!?

Just a few lines of code:

# include this file at the very top of your script

# the code for the class
include ('ajaxCRUD.class.php');

# this one line of code is how you implement the class
$tblCustomer = new ajaxCRUD("Customer",
                             "tblCustomer", "pkCustomerID");

# don't show the primary key in the table

# my db fields all have prefixes;
# display headers as reasonable titles
$tblCustomer->displayAs("fldFName", "First");
$tblCustomer->displayAs("fldLName", "Last");
$tblCustomer->displayAs("fldPaysBy", "Pays By");
$tblCustomer->displayAs("fldPhone", "Phone");
$tblCustomer->displayAs("fldZip", "Zip");

# define allowable fields for my dropdown fields
# (this can also be done for a pk/fk relationship)
$values = array("Cash", "Credit Card", "Paypal");
$tblCustomer->defineAllowableValues("fldPaysBy", $values);

# add the filter box (above the table)

# add validation to certain fields (via jquery in validation.js)
$tblCustomer->modifyFieldWithClass("fldPhone", "phone");
$tblCustomer->modifyFieldWithClass("fldZip", "zip");

# actually show to the table

DB Table for Demo Above

Here is the table used:

    CREATE TABLE tblCustomer(
    fldFName VARCHAR(40),
    fldLName VARCHAR(40),
    fldPaysBy VARCHAR(20),
    fldPhone VARCHAR(15),
    fldZip VARCHAR(5),

(View Demo outside template)

Is it light? Flexible?

4 files! Installs in seconds. The CSS, field validation, and table display is completely customizable.

Ok, I'm sold. Let me try it out!

» Download the code now
» View the Reference Material (Class Documentation)
» View Framework on Github
» View Demo outside template

Need a place to host your web application? At Loud Canvas Media we provide website design and hosting solutions in/around Dover NH.


"I have been using php like 5 years ago, but it feels like it is 20 years ago :-) Now I have found an incredible module AjaxCRUD and damn, this is nice!"

What is a business/commercial website?

A commercial website is one created for a business, for which purpose is generating revenue or cash flow of any type (and that isn't under a non-profit organization). So if you're selling a product, selling advertisement, selling a service, or just marketing a commercial business, your site is commercial. A company website is also commercial even if it doesn't sell anything, as it's purpose is to front a commercial company.