PDA

View Full Version : loop problem


crmpicco
02-24-2005, 05:01 PM
I have a ASP document:

Code:

________________________________________________

<%
Set rs=con.execute("select * from trip_master where agencyid = '"&agencyid&"' and regular_trip = 'Option'")
%>
<table width=700 cellspacing=1 cellpadding=2 border=1 align=center>
<tr bgcolor='#ececec'bordercolor='#cccccc'>
<td align='left'>
<font face='verdana' size=1 color=blue>Name</font>
</td>
<td width='10%' align=center>
<font face='verdana' size=1 color=blue>Status</font>
</td>
<td align='center'>
<font face='verdana' size=1 color=blue>Booking No.</font>
</td>
<td align='center'>
<font face='verdana' size=1 color=blue>Departure Date</font>
</td>
<td align='center'>
<font face='verdana' size=1 color=blue>Itinerary</font>
</td>
<td align='center'>
<font face='verdana' size=1 color=blue>Booking Date</font>
</td></tr>
<%
set rscrm = con.execute("select * from trip_details where trip_id = 'MK/"&rs("A1_pnr")&"' order by tatoo asc")
'response.write ("select * from trip_details where trip_id = 'MK/"&rs("A1_pnr")&"'")
set rscrm2 = con.execute("select dep_airport from trip_details where trip_id = 'MK/"&rs("A1_pnr")&"' order by tatoo asc")
'response.Write ("select dep_airport from trip_details where trip_id = 'MK/"&rs("A1_pnr")&"' order by tatoo asc")
departing_air = rscrm2("dep_airport")
%>
<% while not rs.eof %>
<tr bgcolor='#ececec'bordercolor='#cccccc'>
<td align='left'>
<font face='verdana' size=1><%=rs("leadname")%></font>
</td>
<% if rs("status") = "TL" then %>
<td width='10%' align=center>
<font face='verdana' size=1>Option</font>
</td>
<% else %>
<td width='10%' align=center>
<font face='verdana' size=1><%=rs("status")%></font>
</td>
<% end if %>
<td align='center'>
<font face='verdana' size=1><a href="mytrip_new.asp?pnrno=<%=rs("A1_pnr")%>"><%=rs("A1_pnr")%></a></font>
</td>
<td align='center'>
<font face='verdana' size=1><%=rs("Destination_Arrival_Date")%></font>
</td>
<%
counter = 0
while not rscrm.eof
counter = counter+1

var_arr = rscrm("arr_airport")&"-"

arriving_air = arriving_air & var_arr

'abcd = var_arr+var_arr
'response.write "abcd = " & abcd & "<br>"
'response.write "departure airport = " & var & "<br>"
'response.write "arrival airport = " & var_arr & "<br>"
crm_iti = departing_air&"-"&arriving_air
rscrm.movenext
wend


%>
<td align="center">
<font face='verdana' size=1><%=left(crm_iti,len(crm_iti)-1)%></font>
</td>
<td align="center">
<font face='verdana' size=1><%=rs("date_of_booking")%></font>
</td>
</tr>
<%
rs.movenext
wend
%>
</table>
_______________________________________________

The problem i am having is that the when i am making the crm_iti variable it is only adding the 1st instance of it into the HTML table. Why is this? How can i get round it?

Heres my loop in more detail:

_______________________________________________

<%
counter = 0
while not rscrm.eof
counter = counter+1

var_arr = rscrm("arr_airport")&"-"

arriving_air = arriving_air & var_arr


rscrm.movenext
wend
crm_iti = departing_air&"-"&arriving_air

%>

____________________________________________

the variable crm_iti is added into the HTML table like this:

__________________________________________

<td align="center">
<font face='verdana' size=1><%=left(crm_iti,len(crm_iti)-1)%></font>
</td>

Can anyone see the problem?

vimalpercy
02-25-2005, 11:39 PM
Try this
<%
counter = 0
Do while not rscrm.eof
counter = counter+1

var_arr = rscrm("arr_airport")&"-"

arriving_air = arriving_air & var_arr


rscrm.movenext
Loop
crm_iti = departing_air&"-"&arriving_air

%>

miranda
02-26-2005, 01:17 AM
I dont see anything wrong with the loop perhaps it is something in the rest of the code causing the problem. Without seeing all the code it is hard to tell.