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

   by loud canvas media

AjaxCRUD Class Documentation / Reference Material

<< Reference overview
<< Home


format data in a column with a custom function
void formatFieldWithFunctionAdvanced( String fieldName, String functionName )
Use this function when you wish to format data in your table with a custom function which needs to use logic based on OTHER fields in the row. As such, you have access to the id (primary key) of the row to make logic-based styling decisions.

The parameters of your custom function (which YOU define) must take in TWO arguments ($data and $id) and return your formatted data.


Requires a user-defined function to be set
Type function
Returns formatted data
Default non-formatted data


name of the field you want to format
name of the local function to be invoked


   $tblCar->formatFieldWithFunctionAdvanced('fldPrice', 'displayCarPrice');

   # this function returns the car's price if it's not sold; if so 
   # it says that the car is not for sale and displays the purchase date
   function displayCarPrice($data, $id){
        $carInfo = qr("SELECT fldStatus, fldPurchaseDate 
                                FROM tblCar WHERE pkCarID = $id");
        $status = $carInfo['fldStatus'];
        $purchaseDate = $carInfo['fldPurchaseDate'];

        $return = to_money($data);
        if ($status == 'purchased'){
                $return = "CAR NO LONGER FOR SALE. Sold on $purchaseDate";
        return $return;

See also

New, Edit


"Sweet!!! One of the few packages that runs right out of the box. Just modify a couple of lines[s] [and] it runs perfectly."

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.