Re: Setting integers with decimals into a cell

From: Date: Wed, 03 Jan 2001 10:30:17 +0000
Subject: Re: Setting integers with decimals into a cell
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-5546@lists.php.net to get a copy of this message
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@designsolution.co.uk w: http://www.designsolution.co.uk Nouvotech House, Harbour Road, Oulton Broad, Suffolk, NR32 3LZ, UK -----------------------------------------------------

« previous php.db (#5546) next »