[Wolves] Scuba php calculator
Mike Peters
mike at ice2o.com
Mon Mar 14 22:29:31 GMT 2005
On Mon, 14 Mar 2005 13:21:08 +0000
Wayne Morris <wayne at machx.co.uk> wrote:
> Wayne Morris wrote:
>
> >
> > This all seems a bit easy, am I missing anything?
>
> Ergh, arrays, can't do them!
> Can someone point me in the right direction what to do, here is a
> sample of the data I want to select from and output:
>
> 10m 12m 15m
> A 10 9 8
> B 19 16 13
> C 25 22 17
>
> The way you would use the table is to choose column for your depth and
>
> then look down it for the time you spend at that depth,
> using the next highest number to your time, then the result is the
> letter at the side.
> So 19 mins at 10m would be B, 22mins at 12m would be C, 16 mins at 15m
>
> would be rounded up to 17 mins at 15m = C
>
> I was going to do this with a separate table for each depth, and a
> field for each time interval and do a select like
> (Input query 10m and 25 mins)
> Select * from table 10M where timefieldname= 25, result would be C
> - ok so far.
>
> but for where the timedata was not matched in the table , I would
> either have to do some sort of fancy lookup:
> select next highest timefieldname
> or create a timefieldname for every possible time, and then enter the
> results for each.
>
> Or am I going about this the wrong way?
>
If your table, times, looks like:
+-------+-----+----+-----+
| result | d10 | d12 | d15 |
+-------+-----+----+----+
| A | 10 | 9 | 8 |
| B | 19 | 16 | 13 |
| C | 25 | 22 | 17 |
+-------+-----+----+----+
then:
SELECT result FROM `times` where d15 > 16 order by d15 limit 1;
will give you the first result from column d15 above 16, ie:
+-------+
| result |
+-------+
| C |
+-------+
HTH
--
Mike
Web Site: http://www.ice2o.com
JabberID: mpeters at jabber.org
Registered Linux User #247123
Surprise due today. Also the rent.
More information about the Wolves
mailing list