Avatar of Wayne Barron
Wayne Barron
Flag for United States of America asked on

asp classic loop through and show variable once in a table

Hello, All.
I am trying to get the Quarterly of the months to show as the TOP ROW of a table, for each corresponding set of months.
If I run the following code. <%=ch%>
From the source before, it shows the Quarter for each record, but, of course, it shows it on every row, not at the start of it.

In the "Example HTML Output" below, you will see what I would like the output to be like.

ASP Code
<%while not rsHours.eof
if not rsHours.eof then
chQuarter = DatePart("q", rsHours("PayDate"))
end if
if chQuarter=1 then
ch="First Quarter"
end if
if chQuarter=2 then
ch="Second Quarter"
end if
if chQuarter=3 then
ch="Third Quarter"
end if
if chQuarter=4 then
ch="Forth Quarter"
end if
%>

Open in new window

The Variable in the table.
<tr><td class="tdRight"><%=ch%></td></tr>

Open in new window



The output should look like this.<br />
Having the Quarter name on top of that Monthly Quarter.
In this case, we have the first two quarters of the year shown in the table below.
Example HTML Output
<table>
<tr><td class="tdRight">Date of Pay</td></tr>
<tr><td class="tdRight">Second Quarter></td></tr>
<tr><td class="tdRight">2021-05-02</td></tr>
<tr><td class="tdRight">2021-04-25</td></tr>  
<tr><td class="tdRight">2021-04-18</td></tr>  
<tr><td class="tdRight">2021-04-11</td></tr>
<tr><td class="tdRight">2021-04-04</td></tr>
<tr><td class="tdRight">First Quarter></td></tr>
<tr><td class="tdRight">2021-03-28</td></tr>
<tr><td class="tdRight">2021-03-21</td></tr>
<tr><td class="tdRight">2021-03-14</td></tr>
<tr><td class="tdRight">2021-03-07</td></tr>
<tr><td class="tdRight">2021-02-28</td></tr>
<tr><td class="tdRight">2021-02-14</td></tr>
</table>

Open in new window

Thanks all.
Wayne
ASPVB Script

Avatar of undefined
Last Comment
David H.H.Lee

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David H.H.Lee

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Wayne Barron

ASKER
Thanks, David.
I was about to post that I had figured it out in another way.
However, your way was MUCH easier and quicker.
So, thank you very much for that.

You Rock, David.
Have a good one.

Wayne
David H.H.Lee

you are welcome, Wayne :)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes