Print Page | Close Window

IF statements

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5884
Printed Date: 31 March 2026 at 3:01am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: IF statements
Posted By: ziwez0
Subject: IF statements
Date 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.



Replies:
Posted By: michael
Date Posted: 22 September 2003 at 10:52am
Look into 'ADO Data Shaping' which basically creates a parent child relationship, should work for you.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: ziwez0
Date 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.


Posted By: MorningZ
Date 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 - http://www.4guysfromrolla.com/webtech/092599-1.shtml



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: ziwez0
Date Posted: 23 September 2003 at 7:17am
cheers, sorted it


Posted By: Bluefrog
Date 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.

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net