...

View Full Version : array troubles



crmpicco
01-31-2005, 05:22 PM
My Code:

<% ' Last Edit: CRM 31_jan_05 %>
<!--#Include file="connection.asp"-->
<%
response.write "dbase_name = " & Session("dbase_name") & "<br>"
response.write "comp_code = " & Session("comp_code") & "<br>"
response.write "comp_name = " & Session("comp_name") & "<br>"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Volaro: Display Bookings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="Owner" CONTENT="Volaro Ltd">
<META NAME="Copyright" CONTENT="2004 - Volaro Ltd">
<META NAME="Author" CONTENT="Volaro Ltd">
<script language="javascript">
function refresh()
{
window.location.reload(false);
}

</script>
</head>
<body bgcolor="#F5F5F5">
<form name="form" method="post">
<!-- If a value from the drop-down menu is selected (i.e. Today, One Day Ago etc, etc......)-->
<%
'if request.form("book_date") <> "Please Select" then

book_date = request.form("book_date")
display_all = request.form("display_all")
comp_name = Session("comp_name")
comp_code = Session("comp_code")

bookdate = left(book_date,6)&right(book_date,2)

set rs=con.execute("select * from trip_master where agencyid = '"& comp_code &"' and date_of_booking = '"& bookdate &"'")
response.write "RS = " & ("select * from trip_master where agencyid = '"& comp_code &"' and date_of_booking = '"& bookdate &"'") & "<br>"

A1_pnr = rs("A1_pnr")
'response.write "A1_pnr = " & A1_pnr & "<br>"

set rs2=con.execute("select * from trip_cost where trip_id like '%"& comp_code &"%'")
'response.write "" & ("select * from trip_cost where trip_id like '%"& comp_code &"%'") & "<br>"


'set rs4=con.execute("SELECT trip_id, where trip_id like '%"& A1_pnr &"%' COUNT(*) AS total FROM trip_details GROUP BY trip_id HAVING total > 2;")
'response.write "" &("SELECT trip_id, where trip_id like '%"& A1_pnr &"%' COUNT(*) AS total FROM trip_details GROUP BY trip_id HAVING total > 2;")& "<br>"

%>
<table width="800" border="0" 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="100%" border="1" align="center" bordercolor="#666666" bgcolor="#f5f5f5">
<tr bordercolor="#000000" bgcolor="#336633">
<td align="left" colspan="10">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>Bookings made <%=book_date%> by <%=comp_name%></b></font>
</td>
</tr>
<tr bordercolor="#aaaaaa" bgcolor="#cccccc">
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>PNR No.</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>Leadname</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>Departing</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>Arriving</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>Segments</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>No of Passengers</b>
</font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" style="font-size : 11;">
<b>Status</b>
</font>
</td>
</tr>
<%
while not rs.eof

A1_pnr = rs("A1_pnr")
response.write "A1_pnr = " & A1_pnr & "<br>"

set rs3=con.execute("select * from trip_details where trip_id like '%"& A1_pnr &"%' and orderno = '1'")
response.write "RS3 = " & ("select * from trip_details where trip_id like '%"& A1_pnr &"%' and orderno = '1'") & "<br>"

set rs4=con.execute("select count(trip_id) from trip_details where trip_id like '%"& A1_pnr &"%'")
response.write "RS4 = " & ("select count(trip_id) from trip_details where trip_id like '%"& A1_pnr &"%'") & "<br>"

set rs5=con.execute("select no_of_pass from trip_cost where trip_id like '%"& A1_pnr &"%'")
response.write "RS5 = " & ("select no_of_pass from trip_cost where trip_id like '%"& A1_pnr &"%'") & "<br><br>"

trip_id = rs4("trip_id")
'response.write "Trip ID = " & trip_id & "<br>"

count_trip_id = rs4("count(trip_id)")
'response.write "Count TRIP ID = " & count_trip_id & "<br>"

number_of_passengers = rs5("no_of_pass")
'response.write "Number of Passengers = " & number_of_passengers & "<br>"

segments = cdbl(count_trip_id)*cdbl(number_of_passengers)
response.write "Segments = " & segments & "<br>"

%>
<tr bordercolor="#ececec" bgcolor="#ececec">
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=rs("A1_pnr")%></font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=rs("leadname")%></font>
</td>
<%
smouse=rs("Destination_Arrival_Time")
smouse2=rs("Destination_Arrival_Date")
set rscount=con.execute("select count(trip_details.trip_id) from trip_details INNER JOIN trip_master on (trip_details.trip_id = trip_master.trip_id) where trip_master.regular_trip <> 'Cancelled' and trip_master.date_of_booking = '"& book_date &"'")
total_segments = rscount("count(trip_details.trip_id)")
'response.write "Destination_Arrival_Time = " & smouse & "<br>"
'response.write "Destination_Arrival_Date = " & smouse2 & "<br>"
%>

<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=rs3("dep_airport")%></font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" title="<%=smouse2%>&nbsp;at&nbsp;<%=smouse%>" onmouseover="style.cursor='hand'"><%=rs("Destination_Airport")%></font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=segments%></font>
</td>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=rs5("no_of_pass")%></font>
</td>
<% if rs("regular_trip") = "Cancelled" then %>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000"><b><%=rs("regular_trip")%></b></font>
</td>
<% else %>
<td align="center">
<font face="Verdana, Arial, Helvetica, sans-serif"><%=rs("regular_trip")%></font>
</td>
<% end if ' if rs("regular_trip") = "Cancelled" %>
</tr>
<%

c = segments + segments
response.write "a = " & c & "<br>"

rs.movenext

wend

'response.write "A1 PNR = " & A1_pnr & "<br>"
if A1_pnr <> "" then
%>
<tr bordercolor="#ececec" bgcolor="#ececec">
<td colspan="10" align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Total Number of Segments to date = <%=total_segments%></b></font></td>
</tr>
<% else %>
<tr bordercolor="#ececec" bgcolor="#ececec">
<td></td>
</tr>
<%
end if ' if A1_pnr <> ""
if A1_pnr = "" then
%>
<tr bordercolor="#ECECEC" bgcolor="#ECECEC">
<td colspan="10" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FF0000"><b>Sorry, <br>there are no segments created on the <br><%=book_date%></b></font></td>
</tr>
<% else %>
<tr bordercolor="#ECECEC" bgcolor="#ECECEC">
<td colspan="10">&nbsp;</td>
</tr>
<% end if ' if A1_pnr = "" %>

<tr bordercolor="#dddddd" bgcolor="#eeeeee">
<td align="center" colspan="7">
<input type="button" value="Back" name="back" onClick="history.back(); refresh()" onmouseover="style.cursor='hand'">
</td>
</tr>

</table>

<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>
<% 'end if ' if request.form("book_date") <> "" %>
</form>
</body>
</html>

-----------------------------------------------------------------------

How can i put the variable ' segments ' into an array and then count the TOTAL inside that array?

Typical values are 4, 8 and 20.

Any ideas?

ghell
02-01-2005, 03:38 PM
yea i have a few ideas

1) use a code block, it makes it easier to see
2) only paste a chunk of code not a whole page, that is scary man!

im not sure if this will work but u could try

Eval(Join(arrArrayToTotal, " + "))
to add up all elements in the array, provided they are numeric
i havnt tested it but it shud make it into a string like
"4 + 8 + 20"
and then evaluate that to 32 (if thats what you were asking for)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum