ajaxCRUD.com
» a PHP class to Create, Read, Update, & Delete from a mysql database table using AJAX
by loud canvas mediaAjaxCRUD Class Documentation / Reference Material
|
<< Reference overview << Home Object: ajaxCRUDConstructorFunctions
Variables |
formatFieldWithFunctionformat data in a column with a custom function
void formatFieldWithFunction( String fieldName, String functionName )
Use this function when you wish to format data in your table with a custom function. For example, you'd use this if you wanted to format money to always display looking like a currency.
The parameters of your custom function (which YOU define) must take in ONE argument ($data) and return your formated data. Details
Parameters
ExampleExample 1:
$tblDemo->formatFieldWithFunction('fldCarPrice', 'formatAsCurrency');
function formatAsCurrency($data){
return number_format($data, 2, '.', ','); //displays 10 as 10.00
}
Example 2:
$tblDemo = formatFieldWithFunction("fldImage", "displayImage");
function displayImage($value){
//displays the image instead of just the filename
return "<img src='/images/{$value}' width='100' \>\n";
}
See also |
"Thanks for the great script, you rock big time."
~Daniel
