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
    );


No data in this table. Click add button below.

Class Implementation:


#include the class
include ('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

"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

Leave a Comment

Your Name      
Your Email   
Comment

 

"Very interesting class. Thanks a lot."
~gustavo

What is a commercial website?

A commercial website is a website 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.
Close