Subject | RE: [firebird-support] data display problems |
---|---|
Author | Nigel Weeks |
Post date | 2004-05-27T23:07:49Z |
You're running PHP? Why didn't you say so earlier!
Lay a tiny function on top of your values, and pad out with zeros where
required!
Something like this:
--- Begin Code Listing ---
function pad($val,$places) {
// Test for numeric's first, and exit silently if not
if(is_numeric($val)){
// We have a number. Check for a dot
if(substr_count($val,".") == 0){
// No Dot - append one
$val .= ".";
}
// Now, check that we have enough decimal places, and append as
necessary
// Get the strlen after the dot
$len = (strlen($val) -1) - strrpos($val,".");
// Append zeros
while($len < $places){
// Add one zero on
$val .= "0";
$len++;
}
}
// Return our value
return $val;
}
--- End Code Listing ---
Now, just use it like this:
// Writing it back into the record object
$object->VALUE = pad($object->VALUE,2);
// Preparing it just before output via echo
echo pad($object->VALUE,5);
too easy!!
Nige.
Lay a tiny function on top of your values, and pad out with zeros where
required!
Something like this:
--- Begin Code Listing ---
function pad($val,$places) {
// Test for numeric's first, and exit silently if not
if(is_numeric($val)){
// We have a number. Check for a dot
if(substr_count($val,".") == 0){
// No Dot - append one
$val .= ".";
}
// Now, check that we have enough decimal places, and append as
necessary
// Get the strlen after the dot
$len = (strlen($val) -1) - strrpos($val,".");
// Append zeros
while($len < $places){
// Add one zero on
$val .= "0";
$len++;
}
}
// Return our value
return $val;
}
--- End Code Listing ---
Now, just use it like this:
// Writing it back into the record object
$object->VALUE = pad($object->VALUE,2);
// Preparing it just before output via echo
echo pad($object->VALUE,5);
too easy!!
Nige.
> -----Original Message-----
> From: Alan Davies [mailto:Alan.Davies@...]
> Sent: Thursday, 27 May 2004 11:25 PM
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] data display problems
>
>
> Thanks Daniel - I think I'm missing the pont here. I want to look at
> the data with a non-Delphi product and don't want to "lock" down the
> field to a definite sql query - I re-use queries at runtime and feed
> them with code, rather than having loads of them dotted around a
> datamodule.
> Second point - I want to query the data with PHP - again looking
> at "raw" data.
> Alan
>
>
> > Hi,
> >
> > At May 25, 2004, 16:16, alan davies wrote:
> >
> > > I have tried the Cast() command and also different data
> types - e.g
> decimal
> > > 9,2; numeric 9,2 with no success. I can easily display
> the correct
> format
> > > in a Delphi grid but not in a web page. Can anyone help, please?
> > [...snip...]
> > > Alternatively, how can I force the stored data to respect the
> precision and
> > > scale settings?
> >
> > Use the field display format settings in Delphi.
> >
> > --
> > Best regards,
> > Daniel Rail
> > Senior System Engineer
> > ACCRA Group Inc. (www.accra.ca)
> > ACCRA Med Software Inc. (www.filopto.com)
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor
> --------------------~--
> >
> > Yahoo! Domains - Claim yours for only $14.70
> > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/67folB/TM
> >
> --------------------------------------------------------------------~-
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
> Alan J Davies
> Tel: +44 (0)1926 842069
> Fax: +44 (0)1926 843755
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/67folB/TM
> --------------------------------------------------------------
> ------~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>