I am toying with different methods to look up data in a table. The table is one of a MySQL database and is structured like:
lookup_key int(14),
molow1 numeric(5,2),
mohigh1 numeric(5,2),
movalue1 numeric(5,2),
molow2 numeric(5,2),
mohigh2 numeric(5,2),
movalue2 numeric(5,2),
....
molow30 numeric(5,2),
mohigh30 numeric(5,2),
movalue30 numeric(5,2)
There are also other range prefixes with values such as fmlow1, dmlow1, etc. If a value falls between lowX and highX, I want to use valueX to perform a calculation.
The user will enter information to be looked up into a form ... basically the 'manuf' (lookup_key), 'molevel', 'fmlevel', 'dmlevel', etc. The first solution that comes to mind is to load the table row for that 'manuf' into an array and then walk all the 'mo's , 'fm's, etc. until I find the range where the user's 'molevel' is between 'molowX' and 'mohighX'. Then I know to use 'movalueX' to perform the required calculation.
If I have made myself clear enough, I would appreciate any input those on the board may have to offer. Is there a quicker or easier way?
Thanks In Advance!
wfa