Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 17th, 2005, 12:24 PM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default loop problem - duplication

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="images/top_lefbb.gif" width="16" height="16"></td>
    <td height="16" background="images/top_midbb.gif"><img src="images/top_midbb.gif" width="16" height="16"></td>
    <td width="24"><img src="images/top_rigbb.gif" width="24" height="16"></td>
  </tr>
  <tr>
    <td width="16" background="images/cen_lef.gif"><img src="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'>
Name
</td>
<td width='10%' align=center>
Status
</td>
<td align='center'>
Booking No.
</td>
<td align='center'>
Departure Date
</td>
<td align='center'>
Itinerary
</td>
<td align='center'>
Booking Date
</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'>
<%=rs("leadname")%>
</td>
<td width='10%' align=center>
<%=rs("regular_trip")%>
</td>
<td align='center'>
<a href="mytrip_new.asp?pnrno=<%=rs("A1_pnr")%>"><%=r s("A1_pnr")%></a>
</td>
<td align='center'>
<%=rs("Destination_Arrival_Date")%>
</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">
<%=left(crm_iti,len(crm_iti)-1)%>
</td>
<td align="center">
<%=rs("date_of_booking")%>
</td>
</tr>
<%
rs.movenext
wend
%>
</table>
</td>
    <td width="24" background="images/cen_rigbb.gif"><img src="images/cen_rigbb.gif" width="24" height="11"></td>
  </tr>
  <tr>
    <td width="16" height="16"><img src="images/bot_lefbb.gif" width="16" height="16"></td>
    <td height="16" background="images/bot_midbb.gif"><img src="images/bot_midbb.gif" width="16" height="16"></td>
    <td width="24" height="16"><img src="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


www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
  #2 (permalink)  
Old March 18th, 2005, 11:19 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

This code works:

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

Name Status Booking No. Departure Date Itinerary Booking Date
DOCHERTY Option X8EEVA 21JUN2005 GLA-EWR-GLA- 10/03/05
SMITH Option 2MZ4OX 02NOV2005 GLA-EWR-TPA-EWR-GLA- 08/03/05
COWAN Option ZLER8W 07MAR2005 GLA-EWR-LAX-EWR-EDI- 02/03/05

How do i remove the last '-' from the itinerary string? As you can see above.
e.g. GLA-EWR-GLA- i would want it to say GLA-EWR-GLA

Thanks very much.

Picco

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to avoid duplication of data navbingo20 ASP.NET 2.0 Basics 9 June 8th, 2008 12:14 PM
Content duplication on first page of web site David C Veeneman BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 May 7th, 2006 04:41 PM
help: check duplication when do update in datagrid blur_ivy Classic ASP Basics 0 January 30th, 2005 09:04 AM
show one record if there are duplication yylee Access 1 January 9th, 2005 05:57 AM
Duplication problem mateenmohd SQL Server 2000 0 October 14th, 2003 02:02 AM



All times are GMT -4. The time now is 03:11 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.