ajaxCRUD.com
» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX
by loud canvas mediaQuick Links:
Quick Examples:
- Displaying Images
- Creating a Relationship
- File Uploading
- Using a Where Clause
- Defining Allowable Input
- Formatting a Field With a Function
- Vertical Display
- Show Header Checkbox
- Modify Field with Class
Format Field With Function
Consider the following table:
CREATE TABLE tblDemo(
pkID INT PRIMARY KEY AUTO_INCREMENT,
fldField1 VARCHAR(40),
fldField2 VARCHAR(40),
fldField3 VARCHAR(40),
fldCertainFields VARCHAR(40),
fldLongField TEXT
);
| fldField1 | fldField2 | fldCertainFields | fldLongField | Action |
|---|---|---|---|---|
| 99 | 9000 | My Awesome Value | kk000 | |
| 12 | hdgdgdf | This is another Value | t | |
| 15 | -- | My Awesome Value | -- | |
| Eedaeza | dsaqdeade | NEW Value | dsaezd |
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->omitPrimaryKey();
$tblDemo->formatFieldWithFunction('fldField1', 'makeBlue');
$tblDemo->formatFieldWithFunction('fldField2', 'makeBold');
#actually show to the table
$tblDemo->showTable();
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
"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
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
Leave a Comment
"Brilliant. Saved insane amounts of time. `nuff said."
~Soule

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