|
| |
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
Not sure - return xxx if the count is xx - 12/10/2004 9:31:19
I want to be able to return the statement "All sites Booked" Haven't figured this one out yet.. I don't know if it goes in the first part of the code or the second.. I'm guessing on something like Response.write tempArray(27,i) & "" Changed to something like: If Count(tempArray(27,i)=16 then Response.write "All Sites Booked" else Response.write "" & tempArray(27,i) & "" But that doesn't work.... <%
mySQL = "SELECT * FROM ATTAWANDARON3 WHERE DateStart >=Date() ORDER BY DateStart ASC"
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.Open mySQL, conntemp, 3 , 3
tempArray = myRS.GetRows()
If not myRS.EOF THEN
recordCount = myRS.recordcount
end if
%>
<%
FOR i = 0 to uBound(tempArray,2)
IF i MOD 4 = 0 then
Response.write("<br>")
END IF
if i=0 then
' write the first record
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
Response.write tempArray(27,i) & ""
Response.write " "
else
If tempArray(11,i)=tempArray(11,i-1) then
If tempArray(19,i)=tempArray(19,i-1) then
Response.write tempArray(27,i) & ", "
end if
ELSE
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
Response.write tempArray(27,i) & " "
Response.write ""
'booking number isnt the same as above
end if
end if
next
%>
</TABLE>
<br>
<%
myRS.Close
Set myRS = nothing
conntemp.Close
Set conntemp = nothing
%>
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 9:58:33
quote:
Count(tempArray(27,i)=16 You can't use COUNT on an array element. What actually is tempArray(27,i)? (I should know this... ) Does this have to do with the same items that we looped thru earlier? If so, you could do something similar with the code I posted before using the SPLIT function. Maybe something like this: ... tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write(tempArray(27,i)) END IF .... What this does is build another array based on the elements of tempArray(27,i) and count the elements. Since arrays are 0 based (the first element is 0 instead of 1), we check for the upper element (ubound) to be greater than 14 (which means more than 15 elements). Does that make any sense? ...
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 10:33:20
HI Thanks for the quick reply... I get the same values returning... Would you mind taking a look at the link? Site Yes it's all the same pages... just trying to get different results on different pages.. This page needs to show all current records.. I may have put the code in the wrong places.. here's what I ended up with <%
FOR i = 0 to uBound(tempArray,2)
IF i MOD 4 = 0 then
Response.write("<br>")
END IF
if i=0 then
' write the first record
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write(tempArray(27,i))
END IF
Response.write " "
else
If tempArray(11,i)=tempArray(11,i-1) then
If tempArray(19,i)=tempArray(19,i-1) then
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write(tempArray(27,i))
END IF
end if
ELSE
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write(tempArray(27,i))
END IF
Response.write ""
'booking number isnt the same as above
end if
end if
next
%>
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 11:03:41
It looks like you've put the code in the correct place but the commas are gone from the data in tempArray(27,i). from previous posts on this project, I thought the data had commas separating the elements. Without those commas, tempArray2 will only have 1 element 'cause split(tempArray(27,i),",") uses commas to separate (or split) the item into array elements. Did you follow that? If so, what happened to the commas? Without them (or something else like that; pipes, colons, whatever) we can't split that field.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 11:41:08
It makes sense.. Just can't get it work.. You were right , the commas should be there.. I think this is where Im confused... Do you have to write the array then create the new one out it.. If I put this in each time I refer to the array, I get duplicates... i.e. Response.write tempArray(27,i) & ", " tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & ", " END IF
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 11:45:05
quote:
... Response.write tempArray(27,i) & ", " tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & ", " END IF ... Too much. The code should be just: .... tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & ", " END IF .... See, we don't want to write anything until we check to see if it's full or not. And remember, this won't work without those commas...
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 13:24:58
It's still not working... Not sure if it's me or the code... I understand about the commas, and they are showing in the results page... <%
Dim conntemp, myDSN, myRS, mySQL, tempArray
Set conntemp=Server.CreateObject("ADODB.Connection")
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb")
conntemp.open myDSN
%>
<%
mySQL = "SELECT * FROM ATTAWANDARON3 WHERE DateStart >=Date() ORDER BY DateStart ASC"
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.Open mySQL, conntemp, 3 , 3
tempArray = myRS.GetRows()
If not myRS.EOF THEN
recordCount = myRS.recordcount
end if
%>
<html>
<meta name="Microsoft Theme" content="blends 111">
<body>
<font face="arial">
<p>BOOKINGS - Camp Attawandaron - Sorted by Start Date</font>
</p>
<table border = "2" >
<tr> <td><B> <font size="1">Booking#</font></b></td>
<td><b> <font size="1">Date</font></b></td>
<td><b><font size="1">GROUP</font></b></td>
<td><b><font size="1">LAST NAME</font></b></td>
<td><b><font size="1">SITE(S)</font></b></td>
<%
FOR i = 0 to uBound(tempArray,2)
IF i MOD 4 = 0 then
Response.write("<br>")
END IF
if i=0 then
' write the first record
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i) & ", "
END IF
Response.write " "
else
If tempArray(11,i)=tempArray(11,i-1) then
If tempArray(19,i)=tempArray(19,i-1) then
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i) & ", "
END IF
end if
ELSE
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i),",")
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i) & ", "
END IF
Response.write ""
'booking number isnt the same as above
end if
end if
next
%>
</TABLE>
<br>
<%
myRS.Close
Set myRS = nothing
conntemp.Close
Set conntemp = nothing
%>
<%
Dim conntemp1, myDSN1, myRS1, mySQL1, varBOOKINGNUMBER
Set conntemp1=Server.CreateObject("ADODB.Connection")
myDSN1 ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../fpdb/index.mdb")
conntemp1.open myDSN1
%>
<%
mySQL1 = "SELECT Count(ATTAWANDARON3.BOOKINGNUMBER) AS BOOKINGNUMBER FROM ATTAWANDARON3 GROUP BY BOOKINGNUMBER"
Set myRS1 = Server.CreateObject("ADODB.Recordset")
myRS1.Open mySQL1, conntemp1, 3 , 3
Dim BOOKINGNUMBERCount
BOOKINGNUMBERCount=myRS1.recordcount
%>
<%
myRS1.Close
Set myRS1 = nothing
conntemp1.Close
Set conntemp1 = nothing
%>
</table></body>
</html>
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 14:13:05
Actually I'm a little puzzled myself. Let's try this; change it back to: tempArray2 = split(tempArray(27,i),",") and where this code is: tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & ", " END IF lets make it: tempArray2 = split(tempArray(27,i),",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & ", " & ubound(tempArray2) END IF just to see if we can determine what ubound(tempArray2) evaluates to.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 15:25:37
Interesting I get a 0 at the end of every line....? ? <edit> Major oops!! -I'm ashamed to say I had the wrong ordinal for that field...!!! Go figure that the computer didn't know what I wanted! I went back to an earlier post and the code looks like this... tempArray2 = split(tempArray(28,i),",") IF ubound(tempArray2,2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(28,i) & ", " END IF Error = Microsoft VBScript runtime error '800a005e' Invalid use of Null: 'split' /campbookings1/BookingReview/1BookingsATTNEW_copy(1).asp, line 60
< Message edited by rikki -- 12/10/2004 15:42:11 >
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/10/2004 16:16:56
thanks for your patience! I've got it so the data displays but every field in tempArray(28,i) is empty..?
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 8:32:05
quote:
tempArray2 = split(tempArray(28,i),",") IF ubound(tempArray2,2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(28,i) & ", " END IF 1. What does this section look like right now? 2. What happens if you just put this before it? Response.write(TempArray(28,i))
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 9:40:51
quote:
1. What does this section look like right now? 2. What happens if you just put this before it? tempArray2 = split(tempArray(28,i)&" ",",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(28,i) & ", " END IF Nothing changes when I put response.write(tempArray(28,i)) before that
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 11:34:41
quote:
Nothing changes when I put response.write(tempArray(28,i)) before that Do you get any value for tempArray(28,i)?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rdouglass
Posts: 9202 From: Biddeford, ME USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 11:36:17
quote:
tempArray2 = split(tempArray(28,i)&" ",",") ALso, be carefull. There is not supposed to be any spaces in that line. Should not make a diff, but the code doesn't need any spaces: tempArray2 = split(tempArray(28,i)&"",",")
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 14:10:49
This is where I"m at.... I screwed up and the array should refer to ordinal 27,,, forgot I had removed a field... That's why it was empty! When I changed all back it worked and I got values back.. but the count of > 14 didn't change anything .. Here's the current code... I removed all spaces Any more ideas? Thanks rdouglass... tempArray2 = split(tempArray(27,i)&"",",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i) & "," END IF
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 14:31:26
Maybe be dumb question but where would I place that code? Like this? tempArray2 = split(tempArray(27,i)&"",",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write uBound(tempArray2) END IF
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 14:47:23
Hi Spooky This is what I did and I get an internal server error..??? tempArray2 = split(tempArray(27,i)&"",",") response.write "ARRAY= "&ubound(tempArray2)&"<br>" IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked" ) ELSE Response.write tempArray(27,i)&"," END IF
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 15:01:50
Thanks.. The error now says Microsoft VBScript compilation error '800a041f' Unexpected 'Next' /campbookings1/BookingReview/1BookingsATTNEW_copy(2).asp, line 124 next ^ Here is the whole code... I"ve tried a number of different changes but no go.. <%
FOR i = 0 to uBound(tempArray,2)
IF i MOD 4 = 0 then
Response.write("<br>")
END IF
if i=0 then
' write the first record
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i)&"",",")
response.write "ARRAY= "&ubound(tempArray2)&"<br>"
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i)&","
END IF
else
If tempArray(11,i)=tempArray(11,i-1) then
If tempArray(19,i)=tempArray(19,i-1) then
tempArray2 = split(tempArray(27,i)&"",",")
response.write "ARRAY= "&ubound(tempArray2)&"<br>"
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i)&","
END IF
ELSE
Response.Write "<tr>"
Response.Write "<td>" & tempArray(1,i) & ""
Response.Write "<td>" & tempArray(3,i) & ""
Response.Write " to " & tempArray(4,i) & ""
Response.write "<td>"
IF lcase(trim(tempArray(11,i)))&"" <> "not applicable!" THEN
Response.Write(tempArray(11,i))
END IF
Response.Write "<td>" & tempArray(19,i) & ""
Response.write "<td>"
tempArray2 = split(tempArray(27,i)&"",",")
response.write "ARRAY= "&ubound(tempArray2)&"<br>"
IF ubound(tempArray2) > 14 THEN
Response.write("All Sites Booked" )
ELSE
Response.write tempArray(27,i)&","
END IF
Response.write " "
Response.write ""
'booking number isnt the same as above
end if
end if
next
%>
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 20:33:25
Hi Well, I have the page displaying, but the code that I want to work does not work... tempArray2 = split(tempArray(27,i)&"",",") IF ubound(tempArray2) > 14 THEN Response.write("All Sites Booked") ELSE Response.write tempArray(27,i) & "," END IF It's displaying the value of tempArray(27,i) but doesn't do the replace function.. Sarah
|
|
|
|
BeTheBall
Posts: 6355 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/13/2004 23:15:03
Is this the record that should display the "All Sites Booked" message? ATTTENT6 ATTTENT5, BEAVERBUILDING, GroupCabin1, ATTTENTSITE3, ATTTENTSITE2, BURRLODGE, GroupCabin2, canoes, ATTTENT9, ATTTENT4, ATTTENT8, ATTTENT10, ATTTENT7, ATTRAP, ATTTENTSITE1, I believe it is failing to do so due to the fact there is no comma between ATTENT6 and ATTENT5. As a result, only 14 items are recognized and ubound(tempArray2) > 14 evaluates as false. Just a thought. You could test this theory by changing: ubound(tempArray2) > 14 to ubound(tempArray2) > 5 and see if the All sites Booked message generates for all records where more than 6 sites are booked.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
rikki
Posts: 382 Joined: 4/4/2004 Status: offline
|
RE: Not sure - return xxx if the count is xx - 12/14/2004 9:25:43
Hi Duane I changed the code to add a comma there as I did see that... I've tried different numbers, none work...(well, they don't change anything..) Sarah
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|