Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Issue with Loop

Posted on 2016-08-15
4
Medium Priority
?
79 Views
Last Modified: 2016-08-16
Hi all, I have set up a category of items to display in a 2 wide format.

The 1st and 2nd item display perfectly fine, however the 3rd is missed but the 4th takes its place

Here is the code:
<%
If Request.QueryString("category")>0 Then
		Set CatItins=oConn.Execute("SELECT * FROM itinerary WHERE brand_ID='"&SubDomain("brand_short")&"' AND itin_depdate>#"&NOW()&"# AND itin_type="&Request.QueryString("category")&" AND itin_live=TRUE ORDER BY itin_depdate")
%>
							<table width=1000 border=0 cellpadding=0 cellspacing=0>
								<tr>
									<td width=1000 height=56 bgcolor=white valign=top colspan=3>
										<table bordercolor=<%=BGColor%> bgcolor=<%=BGColor%> border=3 cellpadding=0 cellspacing=0 width=1000 height=50>
											<tr>
												<td>&nbsp;<font class=menu size=5>&nbsp;//&nbsp;<%=HomeRow%></td>
											</tr>
										</table>
									</td>
								</tr>
<%
		Count=1
		Do Until CatItins.EOF
		If Count=1 Then
%>
								<tr>
									<td height=20 colspan=3>&nbsp;</td>
								</tr>
								<tr>
									<td width=490 height=76 bgcolor=white valign=top>
										<table bordercolor=<%=BGColor%> border=3 cellpadding=0 cellspacing=0 width=490 height=278 bgcolor=white>
											<tr>
												<td>	
													<table width=478 height=84 align=center valign=top>
														<tr>
															<td colspan=2 height=30 valign=middle>&nbsp;&nbsp;&nbsp;<img src=http://members.amnet.net.au/~webber4/supplier-<%=CatItins("supplier_ID")%>.png height=26>&nbsp;&nbsp;&nbsp;<font size=5><b><a href=?category=<%=CatItins("itin_type")%>&itin=<%=CatItins("itin_ID")%>><%=CatItins("itin_name")%></a></b></font>
																<br><font size=2>&nbsp;&nbsp;-Nights
<%
			If CatItins("itin_type")=39 Then
				Response.Write("&nbsp;of&nbsp;")
			Else
				Response.Write("&nbsp;from&nbsp;")
			End If
			Set Ports=oConnAE.Execute("SELECT * FROM IATA WHERE IATA='"&CatItins("itin_depcity")&"'")
			Response.Write(Ports("IATA_name")&", ")
%>
																Departs: <%=WeekdayName(Weekday(CatItins("itin_depdate")),TRUE)&"&nbsp;"&CatItins("itin_depdate")%></font></td>
														</tr>
													</table>
													<table width=478 height=190>
														<tr>
<%
			If fs.fileexists("e:\activenquiry.info\www\images\ship-"&CatItins("ship_ID")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/ship-"&CatItins("ship_ID")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			ElseIf fs.fileexists("e:\activenquiry.info\www\images\city-"&CatItins("itin_depcity")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/city-"&CatItins("itin_depcity")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			ElseIf fs.fileexists("e:\activenquiry.info\www\images\country-"&CatItins("itin_depcity")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/country-"&CatItins("itin_depcity")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			Else
				Response.Write("<td align=center valign=top height=180 rowspan=3></td>")
			End If
			Set Cat=oConn.Execute("SELECT * FROM category,category_type WHERE type_ID=cat_type_ID AND itin_ID="&CatItins("itin_ID")&" ORDER BY cat_price")
			TotalCat=0
			Do Until Cat.EOF
			If TotalCat=3 Then
				Exit Do
			Else
				Response.Write("<td height=35 valign=middle style='background-size: cover; background-position: center,center' width=190 align=right><font size=2><b>"&Cat("cat_type_name")&"</b></font>")
				If Cat("cat_soldout")=TRUE Then
					Response.Write("<br><b>SOLD OUT</b>")
				Else
					Response.Write("<br><font size=2>fr <b><font size=4>"&FormatCurrency(Cat("cat_price"),0)&"</font>pp*</b> twin share")
				End If
				Response.Write("</td>")
				Response.Write("</tr>")
				Response.Write("<tr>")
				TotalCat=TotalCat+1
			End If
			Cat.MoveNext
				Loop
%>													</table>
												</td>
											</tr>
										</table>
									</td>
									<td width=20>&nbsp;</td>
<%
			Count=Count+1
		ElseIf Count=2 Then
%>
									<td width=490 height=76 bgcolor=white valign=top>
										<table bordercolor=<%=BGColor%> border=3 cellpadding=0 cellspacing=0 width=490 height=278 bgcolor=white>
											<tr>
												<td>	
													<table width=478 height=84 align=center valign=top>
														<tr>
															<td colspan=2 height=30 valign=middle>&nbsp;&nbsp;&nbsp;<img src=http://members.amnet.net.au/~webber4/supplier-<%=CatItins("supplier_ID")%>.png height=26>&nbsp;&nbsp;&nbsp;<font size=5><b><a href=?category=<%=CatItins("itin_type")%>&itin=<%=CatItins("itin_ID")%>><%=CatItins("itin_name")%></a></b></font>
																<br><font size=2>&nbsp;&nbsp;-Nights
<%
			If CatItins("itin_type")=39 Then
				Response.Write("&nbsp;of&nbsp;")
			Else
				Response.Write("&nbsp;from&nbsp;")
			End If
			Set Ports=oConnAE.Execute("SELECT * FROM IATA WHERE IATA='"&CatItins("itin_depcity")&"'")
			Response.Write(Ports("IATA_name")&", ")
%>
																Departs: <%=WeekdayName(Weekday(CatItins("itin_depdate")),TRUE)&"&nbsp;"&CatItins("itin_depdate")%></font></td>
														</tr>
													</table>
													<table width=478 height=190>
														<tr>
<%
			If fs.fileexists("e:\activenquiry.info\www\images\ship-"&CatItins("ship_ID")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/ship-"&CatItins("ship_ID")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			ElseIf fs.fileexists("e:\activenquiry.info\www\images\city-"&CatItins("itin_depcity")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/city-"&CatItins("itin_depcity")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			ElseIf fs.fileexists("e:\activenquiry.info\www\images\country-"&CatItins("itin_depcity")&".jpg") Then
				Response.Write("<td align=center valign=top height=180 background=http://members.amnet.net.au/~webber4/country-"&CatItins("itin_depcity")&".jpg style='background-size: cover; background-position: center,center' rowspan=3></td>")
			Else
				Response.Write("<td align=center valign=top height=180 rowspan=3></td>")
			End If
			Set Cat=oConn.Execute("SELECT * FROM category,category_type WHERE type_ID=cat_type_ID AND itin_ID="&CatItins("itin_ID")&" ORDER BY cat_price")
			TotalCat=0
			Do Until Cat.EOF
			If TotalCat=3 Then
				Exit Do
			Else
				Response.Write("<td height=35 valign=middle style='background-size: cover; background-position: center,center' width=190 align=right><font size=2><b>"&Cat("cat_type_name")&"</b></font>")
				If Cat("cat_soldout")=TRUE Then
					Response.Write("<br><b>SOLD OUT</b>")
				Else
					Response.Write("<br><font size=2>fr <b><font size=4>"&FormatCurrency(Cat("cat_price"),0)&"</font>pp*</b> twin share")
				End If
				Response.Write("</td>")
				Response.Write("</tr>")
				Response.Write("<tr>")
				TotalCat=TotalCat+1
			End If
			Cat.MoveNext
				Loop
%>													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
<%
			Count=Count+1
		ElseIf Count>2 Then
			Count=1
		End If
		CatItins.MoveNext
			Loop
%>
									
								</tr>
							</table>
<%
End If
%>

Open in new window


I believe it would have to do with this section:
<%
			Count=Count+1
		ElseIf Count>2 Then
			Count=1
		End If
		CatItins.MoveNext
			Loop
%>

Open in new window


however I dont know how to fix it :(

Help please!
0
Comment
Question by:Graeme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41757435
>ElseIf Count>2 Then

should be:
ElseIf Count>=2 Then

because if you processed item 2, you go back to "col1"
0
 

Author Comment

by:Graeme
ID: 41757438
Hi Guy and thank you very much for that, wouldnt that conflict where i already have:
ElseIF Count=2 Then

Open in new window

?

I have tested it and it makes no difference (prob due to the conflict)
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 41757493
actually, you have this p-code:

start_table_output (<table><tr><th> ... </tr></table>)

loop
   if col = 1  do col 1 layout   AND set col + 1
  else if col = 2  do col 2 layout and set col + 1 (which says col3)
  else if col> 2 go to col1
end loop

that makes you skip the 3rd item, as on col2, you should already go back to col1 layout, not to col+1



to make the code more efficient, and eventually allow more columns in the layout without having to code "more", change the code to this logic:
max_cols = 2
col = 1

loop
   if col = 1   do row_start_output (<tr>)
   
   do col_output (<td> ... </td>)
 
   col = col + 1
   if col = max_cols  do row_end_output (</tr>)   AND set col = 1
end loop

if col <= max_cols and col > 1
  while col < max_cols  do   put_empty_col_output (<td></td>)
  do row_end_output (</tr>)
end if

end_table_outputput (</table>)

Open in new window

then, changing from 2 to 5 columns just requires to change max_cols from 2 to 5 ...
which could be dynamic eventually based on browser media size width or so.

hope this helps
0
 

Author Closing Comment

by:Graeme
ID: 41757501
Thanks for that, however it was quite confusing in the way you set it out.

All works, thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question