Re: working with values returned via SQL by cmt
cmt
Wed Apr 30 09:27:42 CDT 2008
On Apr 29, 3:29 pm, "Mike Brind [MVP]" <paxton...@hotmail.com> wrote:
> "cmt" <chrismt...@gmail.com> wrote in message
>
> news:47880cfe-6e54-4b65-89c6-63baf1e486e5@26g2000hsk.googlegroups.com...
>
>
>
> > I have an ASP report that returns values from a SQL database and
> > formats the data in an HTML table.
>
> > I am trying to figure out a good way of using CSS to highlight the
> > table row that contains the highest value returned.
>
> > I tried storing the values in an array, and then used a function to
> > find the highest value. This worked, but then I couldn't really
> > figure out how to "tell" the report to highlight that highest value.
>
> > Could anyone think of an easier way?
>
> > Thanks!
>
> Bob's suggestion is the most straightforward way to approach this, but you
> may have reasons for ordering the results according to a different column.
> If so, when you are looping through the array to write the <tr>'s out,
> simply add an If statement that tests if the current row contains the
> highest value. Asuming that your iterator for the for... next loop on the
> array is i, and the first column contains the value to test:
>
> Response.Write "<tr "
> If arr(0,i) = myHighestValue Then Response.Write "style='background-color:
> red;'"
> Response.Write ">"
>
> --
> Mike Brind
> Microsoft MVP - ASP/ASP.NET
Mike, would this work if I am populating the array in the recordset
loop?
Right now, I have objRs in a loop that populates each <td> has it goes
through the loop. As each value is read via ObjRs, I also add that
value to the array. So the array is not fully populated until the
objRs is finished getting all the data.
Here is a sample of what the code structure looks like:
<table border="1">
<%
h = 0 'hitArray counter
objRs.Open strQry, dbLocation, 1
Do While Not objRs.EOF And Not objRs.BOF %>
<tr>
<td><% Response.Write objRs("urlName")%></td>
</tr>
<tr>
<td><% Response.Write objRs("urlDescription")%></td>
</tr>
<% h = h + 1
ReDim Preserve hitArray(h)
hitArray(h) = (objRs("NumberofHits")) %>
<tr>
<td><% Response.Write objRs("NumberofHits")%>
</tr>
Loop
objRs.Close%>
So the array works...it populates with all of the needed data. But it
is not finished populating until the loop is done running its course.
So I don't think there is a way I could test to see if
objRs("NumberofHits") is the maximum value everytime I write it out.
I hope that makes sense!
Thanks!