RE: [PHP] getting a number range from user input.. (weight)
| From: | Murray @ PlanetThoughtful | Date: | Fri, 05 Nov 2004 05:52:16 +0000 |
| Subject: | RE: [PHP] getting a number range from user input.. (weight) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201259@lists.php.net to get a copy of this message | ||
> OK, here is what it should do.
>
> I have a fixed range of weights from .5 to 20.0 Kg (kilogram) and for
> each weight it has a succeeding value, i cannot jump or just round off
> the numbers. So i need a range detector to do it.
>
> Because for each of the item below:
>
> > weight value
> > .5 9.45
> > 1.0 10.71
> > 1.5 11.97
> > 2.0 13.23
>
> I must get the exact value, so let say for example. I have 1.3 it
> should fall under 1.5 the idea i had was to do this, so i can detect
> where the number should fall..
Put the weight ranges in a MySQL table and use the BETWEEN operator to
retrieve the appropriate weight.
Something like:
fromweight, toweight, value
0,0.5,9.45
0.501,1.0,10.71
1.001,1.5,11.97
Then, the following SQL statement will pull the appropriate value:
SELECT value FROM weights WHERE 1.3 BETWEEN fromweight AND toweight
Much warmth,
Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.