out of desperation i have made a simple and long one and point to a
function. i'll also try ur suggestion, my code is long.

if ($get_WEIGHT_x <= .5) {
        $get_WEIGHT = .5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 1) {
        $get_WEIGHT = 1;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 1.5) {
        $get_WEIGHT = 1.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 2) {
        $get_WEIGHT = 2;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 2.5) {
        $get_WEIGHT = 2.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 3) {
        $get_WEIGHT = 3;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 3.5) {
        $get_WEIGHT = 3.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 4) {
        $get_WEIGHT = 4;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 4.5) {
        $get_WEIGHT = 4.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 5) {
        $get_WEIGHT = 5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 5.5) {
        $get_WEIGHT = 5.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 6) {
        $get_WEIGHT = 6;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 6.5) {
        $get_WEIGHT = 6.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 7) {
        $get_WEIGHT = 7;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 7.5) {
        $get_WEIGHT = 7.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 8) {
        $get_WEIGHT = 8;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 9.5) {
        $get_WEIGHT = 9.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 10) {
        $get_WEIGHT = 10;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 10.5) {
        $get_WEIGHT = 10.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 11) {
        $get_WEIGHT = 11;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 11.5) {
        $get_WEIGHT = 11.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 12) {
        $get_WEIGHT = 12;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 12.5) {
        $get_WEIGHT = 12.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 13) {
        $get_WEIGHT = 13;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 13.5) {
        $get_WEIGHT = 13.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 14) {
        $get_WEIGHT = 14;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 14.5) {
        $get_WEIGHT = 14.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 15) {
        $get_WEIGHT = 15;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 15.5) {
        $get_WEIGHT = 15.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 16) {
        $get_WEIGHT = 16;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 16.5) {
        $get_WEIGHT = 16.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 17.5) {
        $get_WEIGHT = 17.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 18) {
        $get_WEIGHT = 18;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 18.5) {
        $get_WEIGHT = 18.5;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 19) {
        $get_WEIGHT = 19;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x <= 19.5) {
        $get_WEIGHT = 19.5;
        lessthan_20Kg();        
        } elseif ($get_WEIGHT_x <= 20) {
        $get_WEIGHT = 20;
        lessthan_20Kg();
        } elseif ($get_WEIGHT_x >= 20.001) {
        $get_WEIGHT = 9999;
        morethan_20Kg();
}

On Fri, 5 Nov 2004 00:19:15 -0800, Warren Vail <[EMAIL PROTECTED]> wrote:
> Sorry for the delay in getting back to you but I had a long commute tonight.
> 
> Suppose you load an array in high weight order (from the zone that applies).
> 
> weight   value
>  .5          9.45
> 1.0         10.71
> 1.5         11.97
> 2.0         13.23
> 
> load them into an array where like so;
> 
> select weight, zone$zn, from postage_costs
> 
> // looping thru returned rows, load an array ;
>         $zonearray[] = array($weight, $value);
> 
> // then performing lookups;
> 
> unset($postage);
> foreach($zonearray as $entry) {
>     list($wght, $val) = $entry;
>     if($wght >= $actualpkgweight) {
>         $postage = $val;
>           break;
>     }
> }
> if(isset($postage)) // here you have the minimum postage to cover the
> package.
> else                      // here you have a package that weighs more than your 
> largest
> weight
> 
> You can probably figure ways to streamline this, but I think it may answer
> your basic question.  The best solution is one that works for you reliably,
> and there have to be at least 50 ways to do this.  This is just one.
> 
> good luck,
> 
> Warren Vail
> 
> 
> 
> -----Original Message-----
> From: Louie Miranda [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 04, 2004 10:06 PM
> To: Murray @ PlanetThoughtful; [EMAIL PROTECTED]
> Subject: Re: [PHP] getting a number range from user input.. (weight)
> 
> I have this on my db.
> 
> mysql> select * from rates_dhl where weight_kg = "6" between range and
> Weight_KG;
> +----+-------+-----------+--------+--------+--------+--------+--------+-----
> ---+--------+--------+
> | id | range | Weight_KG | Zone_A | Zone_B | Zone_C | Zone_D | Zone_E
> | Zone_F | Zone_G | Zone_H |
> +----+-------+-----------+--------+--------+--------+--------+--------+-----
> ---+--------+--------+
> |  1 | .000  | .5        | 9.45   | 12.29  | 14.18  | 15.12  | 16.59
> | 18.48  | 21.32  | 23.63  |
> +----+-------+-----------+--------+--------+--------+--------+--------+-----
> ---+--------+--------+
> 1 row in set (0.00 sec)
> 
> When i did try the between, even when i try to change the weight_kg to
> any number, it only display the first entry.
> 
> On Fri, 5 Nov 2004 15:52:16 +1000, Murray @ PlanetThoughtful
> <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > 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.
> >
> > --
> >
> >
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> Louie Miranda
> http://www.axishift.com
> 
> --
> 
> 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Louie Miranda
http://www.axishift.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to