Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - IF statements
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

IF statements

 Post Reply Post Reply
Author
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2003 at 10:52am
Look into 'ADO Data Shaping' which basically creates a parent child relationship, should work for you.
Back to Top
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2003 at 7:17am
cheers, sorted it
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bluefrog Quote  Post ReplyReply Direct Link To This Post 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.

 

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.