Forums
This topic is locked
Arrays in ASP + Ultradev
Posted 03 Oct 2001 18:09:20
1
has voted
03 Oct 2001 18:09:20 alex borami posted:
I have a database containing 100 colour names + 1 field for each R, G and B colour value.What I am trying to do is run the following calculation on each record in the database and find the lowest resulting record.
ColDiff = Sqr((r1 - Request("r")^2 + (g1 - Request("g")^2 + (b1 - Request("b")^2)
r1 - recordset.field(RED)
g1 - recordset.field(GREEN)
b1 - recordset.field(BLUE)
The Request() are the fields a user types his RGB values into and posts to this page
I wish to response.write the smallest ColDiff.
If you want to look at the files + database let me know, any help in creating anarray to do this calculation OR any other way to do this would be appreciated!
Thanks in advance,
Alex. Billingsley
Replies
Replied 03 Oct 2001 18:35:26
03 Oct 2001 18:35:26 Joel Martinez replied:
why not try using the min() function... then that way, the RDBMS does the work for you... somethinglike this<pre id=code><font face=courier size=2 id=code>SELECT MIN(Sqr((r1 - Request("r")^2 + (g1 - Request("g")^2 + (b1 - Request("b")^2)) FROM YourTable</font id=code></pre id=code>of course you'd have to make sure you reference the right columns in the SQL statement... but I would try going down that path
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/