Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Table 1

Status
Not open for further replies.

Tumbrick

IS-IT--Management
Sep 2, 2006
7
US
I have a statistics table outputting resellers, their id,purchases and amount.

Eg.

ID - Resllers - Purchases - Amount
101 - ABC - apples - 20
101 - ABC - oranges - 10
303 - DEF - apples - 5
303 - DEF - oranges - 1


Since the Resellers can differ but with different amounts and purchases,

for eligibility can I differ the row colours according to Resellers as they are pulled from the database.
PS The IDs are random not incremental.
Eg. ABC resellers in Blue
DEF resellers in Green

as the Resellers ID changes from the query being pulled from the database.

 
Brute forcing, as it were:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>

<Cfquery name="myresellerquery" datasource="sql">
select 1 as ID, 'blah' as something
UNION ALL
select 1 as ID, 'blah' as something
UNION ALL
select 2 as ID, 'blah' as something
UNION ALL
select 3 as ID, 'blah' as something
UNION ALL
select 3 as ID, 'blah' as something
UNION ALL
select 3 as ID, 'blah' as something
UNION ALL
select 4 as ID, 'blah' as something
UNION ALL
select 5 as ID, 'blah' as something


</cfquery>
<cfset thisreseller = myresellerquery.ID>
<cfset thiscolor = "##ffffff">
<cfset othercolor = "##cfcfcf">
<cfset currcolor = thiscolor>
<table>
<cfoutput query="myresellerquery">
<cfif ID NEQ thisreseller>
<Cfset thisreseller = ID>
<Cfif currcolor EQ thiscolor>
<Cfset currcolor = othercolor>
<cfelse>
<cfset currcolor = thiscolor>
</cfif>
</cfif>
<tr bgcolor="#currcolor#">
<td>#ID#</td><td>#something#</td>
</tr>

</cfoutput>
</table>

</body>
</html>



Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Not NULL-terminated yet.
 
Only after reading your reply, I understood the variable "currcolor" is the second focus of the if statement. Two if, Two temp variables.

My mistake.

Thanks Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top