| Author |
Topic Search Topic Options
|
ziwez0
Groupie
Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
|
Post Options
Thanks(0)
Quote Reply
Topic: IF statements Posted: 22 September 2003 at 4:15am |
|
Hi,
ok i have a access db, with fields called "Location", "Resort","Date","Desc","cost"
"Location" contains ref numbers ie, "11", "22" etc
i then use the IF statement to.....
IF objlocation = "11" Then
Response.write "Manchester"
Else "whatever"
End If
It then goes on to display the rest of the info "Resort","Date"and
"cost".
The problem "Location" values do repeat "11", "11"
but i do not want it to write Manchester more than Once
Example..
MANCHESTER
Resort Date Cost
Resort Date Cost
Resort Date Cost
London
Resort Date Cost
Resort Date Cost
etc.............
any help would be great!
|
|
If anything takes long to do its worth doing.
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 22 September 2003 at 10:52am |
|
Look into 'ADO Data Shaping' which basically creates a parent child relationship, should work for you.
|
|
|
 |
ziwez0
Groupie
Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
|
Post Options
Thanks(0)
Quote Reply
Posted: 23 September 2003 at 3:07am |
|
if writien this..
<html>
<head>
</head>
<body>
<TABLE border=1 bordercolor="lightskyblue">
<%
Dim strLocation
Sub getLocation(olocation)
Select Case olocation
case "11"
If Instr(strLocation," 11#")=0 Then
strLocation=strLocation & " 11#"
response.write "Manchester"
End If
case "33"
If Instr(strLocation," 33#")=0 Then
strLocation=strLocation & " 33#"
response.write "London"
End If
case "22"
If Instr(strLocation," 22#")=0 Then
strLocation=strLocation & " 22#"
response.write "Southhampton"
End If
End Select
End Sub
Dim Conn, dbPath
dbPath = Server.MapPath("/demo/db/SpecialOffersDB.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE=" & dbPath
Set UserRecordset = Server.CreateObject("ADODB.Recordset")
sqlstring = "select * from Special02"
UserRecordset.Open sqlstring, conn
objid = UserRecordset("IDKEY")
objLocation = UserRecordSet("Location")
objDate = UserRecordSet("Date-d")
objhotel = UserRecordSet("hotel")
objdesc = UserRecordSet("desc")
objcost = UserRecordSet("cost")
objuser = UserRecordSet("user")
While NOT UserRecordset.EOF
' ** PASS THE LOCATION VALUE FROM THE DB ON TO THE SUBROUTINE **
' ** 11- MANCHESTER, 22- SOUTHAMPTON, 33-LONDON **
CALL getLocation (objLocation)
Response.Write "<tr><td
bgcolor='#dae8fc'><u><b>&l t;h5>" & objDATE &
"</h5></u></b></td></tr> ;"
Response.Write "<tr><td
bgcolor='#E6E6E6'>" & objhotel & "</td><td
bgcolor='#E6E6E6'>" & objdesc &
"</td><td><font color='orange'><b>" &
objcost & "</b></td></tr>"
UserRecordset.MoveNext
wend
UserRecordset.Close : Set UserRecordset=nothing
conn.close : Set conn=nothing
%>
</table>
</body>
</html>
but it only repeats 1 entry out of the db,
ie
MANCHESTER
27th October
Hilton : 7 nights only : £259
27th October
Hilton : 7 nights only : £259
27th October
Hilton : 7 nights only : £259
when what i need is
MACHESTER
27th October
Hilton : 7 nights only : £259
1st December
Holidat Inn : 7 nights only : £358
LONDON
13th October
Holiday Inn : 7 nights only : £444
SOUTHAMPTON
24th October
FairView Hotel : 7 Nights only : £259
|
|
If anything takes long to do its worth doing.
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 23 September 2003 at 7:15am |
as Michael mentioned... Data Shaping would be the perfect solution...
check out the explainations/examples at 4guys: http://www.4guysfromrolla.com/webtech/092599-1.shtml
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
ziwez0
Groupie
Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
|
Post Options
Thanks(0)
Quote Reply
Posted: 23 September 2003 at 7:17am |
|
cheers, sorted it
|
 |
Bluefrog
Senior Member
Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
|
Post Options
Thanks(0)
Quote Reply
Posted: 23 September 2003 at 7:18am |
Here's a cheapo answer:
Set a variable to tell you when something is "new", then if it is, write "Manchester", if not, don't.
e.g.
theString="" ' initialize the variables theLastString="0" Loop
theString=objRS("City") if theString=theLastString then ' do nothing else response.write theString end if theLastString=theString objRS.moveNext
End loop
Of course you'd have all your other stuff in there.
|
 |