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

   by loud canvas media

Quick Links:

Quick Examples:

Format Field With Function

Consider the following table:

    CREATE TABLE tblDemo(
    fldField1 VARCHAR(40),
    fldField2 VARCHAR(40),
    fldField3 VARCHAR(40),
    fldCertainFields VARCHAR(40),
    fldLongField TEXT

dfsfds -- -- --
test Okay NEW Value get some
Blue Test This is another Value --
2232 23333 This is another Value 21
dfgdfg -- -- --
11 22 33 44
lol -- OLD Value --
Rjjj B OLD V B

Class Implementation:

#required file and class
require_once ('preheader.php');
include_once ('ajaxCRUD.class.php');

#this one line of code is how you implement the class
$tblDemo = new ajaxCRUD("New Item", "tblDemo", "pkID");


$tblDemo->formatFieldWithFunction('fldField1', 'makeBlue');
$tblDemo->formatFieldWithFunction('fldField2', 'makeBold');

#actually show to the table

function makeBold($val){
	return "<b>$val</b>";

function makeBlue($val){
	return "<span style='color: blue;'>$val</span>";

View Example by Itself

Click here to view example outside of the template.

Recent Feedback

"Very interesting class. Thanks a lot. A little suggestion: when I edit a cell, but leaving the original value, an Error message says:"Error updating content.". It would be easier if `Cancel` button nor Error message appear.

" - Posted by gustavo on Friday Jan 8th, 2010 at 11:45am

"haha. wow. i never knew this existed!" - Posted by Jason on Saturday Apr 17th, 2010 at 9:47pm

"Great!! Thanks guys" - Posted by Rolly on Wednesday Nov 3rd, 2010 at 9:46pm

"All you are a fucking bitches" - Posted by The Silly Boy on Wednesday Nov 24th, 2010 at 8:03am

"Is there a possibility to make a "update"-Action instead of "delete"-Action?" - Posted by Max on Saturday Dec 11th, 2010 at 11:42pm

"As Kimmy from Kath & Kim says: noice!" - Posted by lola_fatty_cunty on Sunday Jun 26th, 2011 at 7:59am

"Hi, GREAT library that make my projects much easier!!! Thanks.

One hint: if you define a relationship (defineRelationship) you cannot use formatFieldWithFunction to e.g. format the field with the changed display of the content "blue". I tried it with the field-name of the table and the related field name of the foreign table...

Best wishes, Martin
" - Posted by Martin on Tuesday Aug 9th, 2011 at 4:48pm

"Just so you know, your post is not showing up right in my feed draeer (google draeer). This is the text that I gotDump The Land Line .adHeadline {font: bold 10pt Arial; text-decoration: underline; color: #65dd00;} .adText {font: normal 10pt Arial; text-decoration: none; color: #E6E6E6;}try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==``?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(" - Posted by Yudie on Sunday Mar 25th, 2012 at 7:22am

"yes, this comment system looks quite inteligent." - Posted by ilham on Wednesday Aug 8th, 2012 at 2:51pm

How could I add pkid manually on add my item?
" - Posted by Mollo on Saturday Nov 30th, 2013 at 6:58pm

Leave a Comment

Your Name      
Your Email   


"Thanks a bunch for this class. Man, it really does make turning around a CRUD quickly with cool fade effects for managers. Thanks for making this."

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.