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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ok, heres a toughy - for me. 1

Status
Not open for further replies.

schase

Technical User
Joined
Sep 7, 2001
Messages
1,756
Location
US
on
we have individual pilots - I display their respective scores great. Now these pilots also belong to "squads" which I would like to show those as well - but in the following manner.

SQUAD - GVFForce
Callsign Score Kills Death
Magnum - 50 50 2
FireFoxx - 45 34 5
Archer - 31 64 10
Total - 126 148 17

SQUAD - Alpha
Callsign Score Kills Death
Pilot1 - 56 64 8
Pilot2 - 44 74 15
Total - 100 138 23

And so on.

Any ideas? When I lay it out and try to repeat region it likes to put the squad's name, then a pilot - then squads name, then another pilot, etc.

Thank you
 
Hi

Non repeating headers... nice to do, pants to explain and type!

Make sure your recordset is in SQUAD, CALLSIGN order.

Crack open the HTML and go to the point where you start the While NOT rs.EOF loop.
Before the loop add a new variable:

[/code]squadhead = ""[/code]

Then once within the loop:

Code:
If rsSquads(&quot;squadname&quot;)<>squadhead then
   ' this is a different squad group
   response.write(add your code here for the table header and squad name etc.)
   squadhead=rsSquads(&quot;squadname&quot;)
End if

So, when you hit a different squad name you will output your table &quot;header&quot; with the name, and the headings for call sign, kills, etc., but any subsequent rows the squad will match squadhead and just put out the data row.

Sorry it's rushed, but I'm off out in a minute.

Good luck

Derren
[The only person in the world to like Word]
 
hmmm, close I think

Heres what I've got - I've moved the IF statement up to just after the EOF but to no change.
What it does is lists all the squads up top - then repeats callsign/score/kills/death row - then a pilots info - then total and swings back to callsign/score/kills/death for the next pilot.




<% squadhead = &quot;&quot;
While ((Repeat2__numRows <> 0) AND (NOT rsSquads.EOF))


%>
<tr>
<td colspan=&quot;4&quot; class=&quot;gvff&quot;></td>
</tr>
<tr>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Callsign</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Score</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Kills</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Death</font></td>
</tr>
<tr>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;callsign&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of score&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of kills&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of death&quot;).Value)%></td>
</tr>
<tr>
<td>Total</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<% If rsSquads(&quot;squad&quot;)<>squadhead then
' this is a different squad group
response.write(rsSquads.Fields.Item(&quot;squad&quot;).Value)
squadhead=rsSquads(&quot;squad&quot;)
End if
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsSquads.MoveNext()
Wend
%>
 
That's looking more like it. Is that finished then?

Hopefully you moved the squadhead part to the start of the loop, just before

<tr>
<td colspan=&quot;4&quot; class=&quot;gvff&quot;></td>
</tr>

At least it looks like you have done that.

Please contact again if you need more help

Derren
[The only person in the world to like Word]
 
i'm close, real close,

but how can I get where I have

GVFForce (repeats squad name a-ok)
then show
callsign score kills death (to repeat right under each squad name.

Then a total at the bottom of each group of records totalling the squad's scores, kills, deaths? oh and a space between the squads.

or would it be better to put the totals up next to the squad name?

 
Nothing is impossible!

Headers first. There is no difference between writing a header and putting in the squadron name. You even put them in at the same time.

Code:
<% If rsSquads(&quot;squad&quot;)<>squadhead then
   ' this is a different squad group
   squadhead=rsSquads(&quot;squad&quot;)
   ' No using response.write here as its a lot of code
   ' All this is your squad header %>
<tr background=&quot;../images/web/background.gif&quot;> 
   <th colspan=&quot;4&quot; class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;squad&quot;).Value)%></th>
</tr>
<tr background=&quot;../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Callsign</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Score</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Kills</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Death</font></td>
</tr>
<% End if %>

Now the totals are a little more tricky because we are going to put them in after the squad has finished. In other words when the squadname changes. Sound familiar? For each of your totals that you want to count create a variable above the While loop and make them all 0

Code:
scoretotal=0
killtotal=0
deathtotal=0

To add the values up, do it when you output each callsign:

Code:
scoretotal = scoretotal + rsSquads(&quot;sum of score&quot;)
killtotal = killtotal + rsSquads(&quot;sum of kills&quot;)
deathtotal = deathtotal + rsSquads(&quot;sum of death&quot;)
' then proceed to add the row text...

This will happily add them up as you go. But when to write? When to reset the value back to zero? Aha! In the header bit ...

Code:
><% If rsSquads(&quot;squad&quot;)<>squadhead then
   ' this is a different squad group
   ' Now output scores from PREVIOUS squad
   If squadhead <> &quot;&quot; then
      ' This is an important test because we dont want to
      ' output the scores when we first hit the loop %>
<tr background=&quot;../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
   <% ' Now RESET the values
      scoretotal=0
      killtotal =0
      deathtotal=0
   End if

   ' Continue with code for header
   squadhead=rsSquads(&quot;squad&quot;)
   ' No using response.write here as its a lot of code
   ' All this is your squad header %>
<tr background=&quot;../images/web/background.gif&quot;> 
   <th colspan=&quot;4&quot; class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;squad&quot;).Value)%></th>
</tr>
<tr background=&quot;../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Callsign</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Score</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Kills</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Death</font></td>
</tr>
<% End if %>

Right! Now the only question remaining is how to output the LAST row. Well, when is it after the last row - after the loop has finished of course - at EOF. After the last Wend:

Code:
<%' output scores of last squad
   If squadhead <> &quot;&quot; then
      ' This is an important test because we dont want to
      ' output the scores if we have no records in the recordset %>
<tr background=&quot;../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
<% End if %>

All done. You can add space to the bottom of each squad by putting it after the code to write out the scores.

Derren
[The only person in the world to like Word]
 
wow your good

And very close. now I've put the
scoretotal=0
killtotal=0
deathtotal=0

'To add the values up, do it when you output each callsign:

scoretotal = scoretotal + rsSquads(&quot;Sum of score&quot;)
killtotal = killtotal + rsSquads(&quot;Sum of kills&quot;)
deathtotal = deathtotal + rsSquads(&quot;Sum of death&quot;)

part where it is below on the code and right after the <% squadhead=&quot;&quot;
either way it shows zero for each one.

Interesting note - before I moved it to where it is now (below) the first squad group - showed nothing for totals - not even zero's. at this point i'm showing zero's at anyrate.





<table width=&quot;347&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<% squadhead=&quot;&quot;


While ((Repeat2__numRows <> 0) AND (NOT rsSquads.EOF))
%>
<% If rsSquads(&quot;squad&quot;)<>squadhead then
' this is a different squad group
' Now output scores from PREVIOUS squad
If squadhead <> &quot;&quot; then

scoretotal=0
killtotal=0
deathtotal=0

'To add the values up, do it when you output each callsign:

scoretotal = scoretotal + rsSquads(&quot;Sum of score&quot;)
killtotal = killtotal + rsSquads(&quot;Sum of kills&quot;)
deathtotal = deathtotal + rsSquads(&quot;Sum of death&quot;)
' This is an important test because we dont want to
' output the scores when we first hit the loop %>
<tr background=&quot;../../images/web/background.gif&quot;>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
<% ' Now RESET the values
scoretotal=0
killtotal =0
deathtotal=0
End if

' Continue with code for header
squadhead=rsSquads(&quot;squad&quot;)
' No using response.write here as its a lot of code
' All this is your squad header %>
<tr background=&quot;../../images/web/background.gif&quot;>
<th colspan=&quot;4&quot; class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;squad&quot;).Value)%></th>
</tr>
<tr background=&quot;../../images/web/background.gif&quot;>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Callsign</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Score</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Kills</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Death</font></td>
</tr>
<% End if %>

<tr>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;callsign&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of score&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of kills&quot;).Value)%></td>
<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of death&quot;).Value)%></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsSquads.MoveNext()
Wend
%>
<%' output scores of last squad
If squadhead <> &quot;&quot; then
' This is an important test because we dont want to
' output the scores if we have no records in the recordset %>
<tr background=&quot;../images/web/background.gif&quot;>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
<% End if %>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
 
OK, this should be the final code. I have put commetns in but generally you did two things wrong:

1) when you hit a new squad and went to output the scores you set them all to zero (d'oh!)

2) you then put the adding part in the same bit, so the only time it would add the values would be when it reached a new squad, not for each callsign (double d'oh!)

Here it is then:

Code:
<table width=&quot;347&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<% squadhead=&quot;&quot;
While ((Repeat2__numRows <> 0) AND (NOT rsSquads.EOF)) 
%>
<% If rsSquads(&quot;squad&quot;)<>squadhead then
   ' this is a different squad group
   ' Now output scores from PREVIOUS squad
   If squadhead <> &quot;&quot; then
   ' DONT reset your values here, we haven't written them yet!
   
      ' This is an important test because we dont want to
      ' output the scores when we first hit the loop %>
<tr background=&quot;../../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
   <% ' Now RESET the values
      scoretotal=0
      killtotal =0
      deathtotal=0
   End if

   ' Continue with code for header
   squadhead=rsSquads(&quot;squad&quot;)
   ' No using response.write here as its a lot of code
   ' All this is your squad header %>
<tr background=&quot;../../images/web/background.gif&quot;> 
   <th colspan=&quot;4&quot; class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;squad&quot;).Value)%></th>
</tr>
<tr background=&quot;../../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Callsign</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Score</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Kills</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Death</font></td>
</tr>
<% End if %>
<% 
' Once you have done your header checks you can NOW deal with each record
' To add the values up, do it when you output each callsign:
scoretotal = scoretotal + rsSquads(&quot;Sum of score&quot;)
killtotal = killtotal + rsSquads(&quot;Sum of kills&quot;)
deathtotal = deathtotal + rsSquads(&quot;Sum of death&quot;)
%>
	  <tr> 
		<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;callsign&quot;).Value)%></td>
		<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of score&quot;).Value)%></td>
		<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of kills&quot;).Value)%></td>
		<td class=&quot;gvff&quot;><%=(rsSquads.Fields.Item(&quot;Sum Of death&quot;).Value)%></td>
	  </tr>
      <% 
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  rsSquads.MoveNext()
Wend
%>
<%' output scores of last squad
   If squadhead <> &quot;&quot; then
      ' This is an important test because we dont want to
      ' output the scores if we have no records in the recordset %>
<tr background=&quot;../images/web/background.gif&quot;> 
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot;>Squad totals:</font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=scoretotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=killtotal%></font></td>
<td><font color=&quot;#CCCCCC&quot; face=&quot;Impact&quot; size=&quot;2&quot; align=&quot;right&quot;><%=deathtotal%></font></td>
</tr>
<% End if %>
  <tr> 
	<td> </td>
	<td> </td>
	<td> </td>
	<td> </td>
  </tr>
</table>

Paste that little puppy in and see what happens! Derren
[The only person in the world to like Word]
 
OHHHHHHHHHHHHHHHH

yeah that was rather dumb

on both accounts.

works perfectly!

You da man!

I put a neat little line divider in there too.

you are da man! (did I mention that?)

Hey MLawson - lookout - theres another smart*** here in UD forum!

hehe

[2thumbsup]
 
Oh, that looks superb! A good job done all round!

Thanks for the comments, it's nice to be able to help.

Take it easy and remember to look up from the PC every now and again ... Derren
[The only person in the world to like Word]
 
Oh, that looks superb! A good job done all round!

Thanks for the comments, it's nice to be able to help.

Take it easy and remember to look up from the PC every now and again ...

[cheers] Derren
[The only person in the world to like Word]
 
Well done Derren.

See, it is good to be able to get UD and ASP to work together, good to see someone who knows their ASP from their elbow!!

Have fun!

M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top