www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > ASP

    ASP Discussion and technical support for using and deploying Active Server Pages.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-10-2006, 08:10 AM
    RickyM RickyM is offline
    Registered User
     
    Join Date: Mar 2006
    Posts: 6
    ASP to select information from a database

    WE have this html file to start with:

    http://files.dmusic.com/music/r/i/rickym/image1.JPG

    When, for example the Aberdeen link is clicked an asp screen like this should come up:

    http://files.dmusic.com/music/r/i/rickym/image2.JPG

    Here is the HTML file I have done:

    HTML Code:
    <h4 align=center>Quality Accommodation In Scotland</h4>
    
    
    <p>
    Looking for an <a href="P10_2.asp?city=Aberdeen">Aberdeen</a> hotel? 
    Searching for rest and relaxation in rural 
    <a href="P10_2.asp?city=Inverness">Inverness</a>? 
    Or are you preparing to savour the 
    flavour of <a href="P10_2.asp?city=Edinburgh">Edinburgh</a>? 
    Whichever type of hotel stay you’re after we offer the very best in Scottish 
    hotels. From the 
    homely simplicity of the a small, family run hotel to the grandeur of some of 
    the best and most luxurious hotels 
    in Scotland, we have something to suit every taste and every pocket.
    </p>
    <br>
    <p>
    Our hotel accommodation ranges from quality cheap 2 star hotels, up to 4 star 
    luxury hotels. Use the 
    <a href="P10_3.html">search</a> page to find the right accommodation to suit 
    your holiday budget or check out our <a href="P10_5.asp">special offers</a> 
    for a real bargain! Our accommodation only prices give you freedom to 
    choose your preferred travel arrangements.
    </p>
    
    
    </body>
    </html>
    And the ASP file:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>P10_2</title>
    <script src="P10.js" type="text/javascript" language="JavaScript">
    </script>
    <link rel="stylesheet" type="text/css" media="screen" href="P10.css" />
    </head>
    <body>
    
    
    <% 
    'Links to the database stored in the folder'
    
    dbname = "Scotland.mdb"
    cnpath = "DBQ=" + Server.mappath(dbname)
    connStr = "DRIVER={Microsoft Access Driver (*.mdb)}; " + cnpath
    Set connect = Server.CreateObject("ADODB.Connection")
    Set results = Server.CreateObject("ADODB.Recordset") 
    connect.Open(connStr)
    citychoice = request.QueryString("city")
    
    'SQL statement which selects the hotels depending on which link is clicked from the HTML file
    sql = "SELECT * FROM hotels WHERE city = '"&citychoice&"'"
    
    results.open sql, connect, 3, 3
    %>
    
    <h4>Hotels in <%=citychoice%></h4>
    
    <%If citychoice="Aberdeen" Then %>
    	<p>Aberdeen is the ideal location for shopping, sightseeing and relaxing. Take some time to unwind and revive 
    	yourself with a combination of fine wines and gourmet food  - you'll find luxurious comfort 
    	at affordable prices. Aberdeen is the perfect winter setting for taking a break. Get active in the great outdoors, discover the delights of 
    	the Castle Trail or blow the cobwebs away with a walk on the sandy shores and cliffs of our dramatic coastline.
    	Whatever you decide a warm welcome awaits.
    	</p>
    	
    <%ElseIf citychoice="Edinburgh" Then %>
    	<p>Edinburgh, the capital of Scotland, is one of the most beautiful cities in Europe. Its magnificent architecture 
    	shifts from the lofty tenements and narrow closes of its medieval Old Town to the grace and geometric precision of 
    	the Georgian New Town. Overlooking the city, in its towering splendour, stands Edinburgh Castle. Edinburgh is both 
    	a compact city and a bustling city but above all a city which rewards every visitor.
    	</p>
    
    <%ElseIf citychoice="Inverness" Then%>
    	<p>Granted city status in December 2000, Inverness has an enviable location at the head of the Great Glen and on the 
    	shores of the Moray Firth. In and around Inverness, you can also choose from numerous places to visit and things to do.
    	The city is dissected by the charming River Ness and overlooking the river is Inverness Castle. Contemporary local art is always on display 
    	in the many galleries throughout the city and traditional Scottish entertainment is on offer at the Spectrum Centre 
    	Theatre in the shape of Scottish Showtime, with traditional Scottish dancing.
    	</p>
    <%End If%>
    
    <br />
    <% Do until results.EOF %>
     	
     	<span class=green><% =results("name") %></span><img src="<%=results("rating")%>star.gif"> <br>
     	<% =results("description") %> <br>
     	<span class=red>£<% =results("price") %> per room per night</span><br><br>
     	<%If results("parking")= "Y" Then%> <img src="parking.gif"><%End If%>
     	<%If results("bar")= "Y" Then%> <img src="bar.gif"><%End If%>
     	<%If results("swimmingPool")= "Y" Then%> <img src="swimpool.gif"><%End If%>  
     	<a href="javascript:test()">key</a>
     	<br>
     	<hr>
     	
     	
    <% results.MoveNext 
    loop 
    %>
    
    <br /><br />
    <a href="P10_1.html">home page</a>
    </body>
    </html>
    At the minute, with this code that I have done, the whole text is coming up, not the information specific to each town/city, like the information given in the 2nd sceenshot.

    If anyone can tell me where I'm going wrong with this ASP file, I would be grateful.
    Thanks
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:04 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.