PDA

View Full Version : If Then Else contained in Loop



MrJL
Jul 2nd, 2002, 01:04 AM
Ok, I'm sure there some elementary mistake I'm making in my logic here, but here's my code:


<%
while not infoRS.eof
IF State = infoRS.fields("state") THEN
response.write "<tr><td>&nbsp;</td><td>" & infoRS.fields("city") & "</td></tr>"
ELSE
Set State = infoRS.fields("state")
response.write "<tr><td>" & infoRS.fields("state") &"</td><td>" & infoRS.fields("city") & "</td></tr>"
END IF
infoRS.movenext
wend
%>

And instead of getting a nicely laid out table where I have one state, multiple cities, and then another state listed, with more cities...

I have one state listed at the top left, and every city listed. No more states. Here's the page: http://www.mickeysguidingstuff.net/patches/unitedstates/content.asp

Far warning, it cycles thru about 319 records. So it'll take a second or two to process. At least, it has with me. I've trimmed some code out of my example here. Namely, an entire column. But you get the idea of what I'm wanting it to, I hope.

Is it something simple? Got things in the wrong order or something? It seems like it should work from here. The logic of it, anyway. But it's not doing what I want. :(

Any ideas?

Jer!

MrJL
Jul 2nd, 2002, 01:47 AM
Great!

Thanks a bunch! :-)

Jer!