Re: [HDLLC] sorting numbers entered as string data
This code has been moved with later versions of CMS Builder to the top of the page.
A sample of one that we used is:
<?php
require_once "/home/remaxc/public_html/webadmin/lib/viewer_functions.php";
list($commercialRecords, $commercialMetaData) = getRecords(array(
'tableName' => 'commercial',
'orderBy' => 'price+0 DESC',
));
$commercialRecord = @$commercialRecords[0]; // get first record
?>
But also in the field where price is displayed, you can ensure that it actually looks like a "price" by adding a few extra codes:
$<?php echo number_format($commercialRecord['price'] ,2) ?>
The ",2" tells it to give two decimal places
The "number_format" tells it to treat it like a number to include comma separators.
Notice the "$" before the echo statement - that's just embedded into the code so it shows up automatically for every price.
On the backend, we just allow the user to enter in numbers.
So they would enter in 3456 (or 3456.00)
And what would be displayed is $3,456.00