codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  loop problem - duplicating everytime  crmpicco at 16:25 on Thursday, March 17, 2005
 

I have this form in my asp page:

<form name="form">
<%
Set rs=con.execute("select * from trip_master where agencyid = '"&agencyid&"' and regular_trip <> 'Cancelled' order by pri_key desc")
response.write ("select * from trip_master where agencyid = '"&agencyid&"' and regular_trip <> 'Cancelled' order by pri_key desc")
%>
<table width="800" border="0" bordercolor="#ECECEC" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="16"><img src="/forum/images/top_lefbb.gif" width="16" height="16"></td>
<td height="16" background="/forum/images/top_midbb.gif"><img src="/forum/images/top_midbb.gif" width="16" height="16"></td>
<td width="24"><img src="/forum/images/top_rigbb.gif" width="24" height="16"></td>
</tr>
<tr>
<td width="16" background="/forum/images/cen_lef.gif"><img src="/forum/images/cen_lef.gif" width="16" height="11"></td>
<td>
<table width=800 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>
<%

'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 %>
<% set rscrm = con.execute("select * from trip_details where trip_id = 'MK/"&rs("A1_pnr")&"' order by tatoo asc")%>
<tr bgcolor='#ececec'bordercolor='#cccccc'>
<td align='left'>
<font face='verdana' size=1><%=rs("leadname")%></font>
</td>
<td width='10%' align=center>
<font face='verdana' size=1><%=rs("regular_trip")%></font>
</td>
<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>
<%
while not rscrm.eof
var_arr = rscrm("arr_airport")&"-"
arriving_air = arriving_air & var_arr
rscrm.movenext
wend
crm_iti = departing_air&"-"&arriving_air
%>
<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>
</td>
<td width="24" background="/forum/images/cen_rigbb.gif"><img src="/forum/images/cen_rigbb.gif" width="24" height="11"></td>
</tr>
<tr>
<td width="16" height="16"><img src="/forum/images/bot_lefbb.gif" width="16" height="16"></td>
<td height="16" background="/forum/images/bot_midbb.gif"><img src="/forum/images/bot_midbb.gif" width="16" height="16"></td>
<td width="24" height="16"><img src="/forum/images/bot_rigbb.gif" width="24" height="16"></td>
</tr>
</table>
</form>

____

The problem i am having is that i cannot stop my loop adding the results together. My output in a browser is:

Name Status Booking No. Departure Date Itinerary Booking Date
a Confirmed ZKXIVF 10MAY2005 GLA-EWR-SFO-EWR-GLA 17/03/05
A Option ZKBQYJ 12MAY2005 GLA-EWR-SFO-EWR-GLA-DXB-AKL-DXB-GLA 17/03/05
A Option ZJUJH4 10MAY2005 GLA-EWR-SFO-EWR-GLA-DXB-AKL-DXB-GLA-EWR-MEM-EWR-GLA 17/03/05

___

what is happening is that my itinerary is being added up again, and again. as the page goes down it ends up like this:

GLA-EWR-SFO-EWR-GLA-DXB-AKL-DXB-GLA-EWR-MEM-EWR-GLA-DXB-AKL-DXB-GLA-PHL-SFO-PHL-GLA-AMS-MAD-AMS-GLA-DXB-MEL-DXB-GLA

How can i cut it off?

Heres my loop in more detail:

<%
while not rscrm.eof
var_arr = rscrm("arr_airport")&"-"
arriving_air = arriving_air & var_arr
rscrm.movenext
wend
crm_iti = departing_air&"-"&arriving_air
%>

and i output my itinerary to the screen with this asp:

<%=left(crm_iti,len(crm_iti)-1)%>

thanks.

Picco









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007