Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2001011

Re: [PHP-DB] Setting integers with decimals into a cell From: Glen Scott (glen <email protected>)
Date: 01/03/01

Hi Mattias,

At 16:18 31/12/00, Mattias Johansson wrote:
>I have almost finished my evil new-years-eve project, but I have run into
>the last problem of them all. You see - I have a variable that usually
>produces a number like this: 4.17349837364732. I want this to be 4.17 and
>set it into a MySQL database. How can this be done? I currently have the
>field in question set to TINYINT, but that does not seem to work. Can anyone
>please help me with this little problem?

Use the round function in PHP:

http://www.php.net/manual/function.round.php

Or even better, use the MySQL datatype FLOAT(4,2) which will automatically
convert inserted numbers to two decimal places.

Regards,

Glen

-----------------------------------------------------
   Design Solution Limited
   t: +44 (0)1502 513008
   f: +44 (0)1502 588622
   e: info <email protected>
   w: http://www.designsolution.co.uk
   Nouvotech House, Harbour Road,
   Oulton Broad, Suffolk, NR32 3LZ, UK
-----------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>