UltraDev 101

Detail Pages - Connecting to the Database and Passing Variables
  


  


We want to expand our database a bit more. We want to be able to click a person first name and have it pull up the details ONLY for that person. There are a few quick steps we can take to achieve this.

First we need to create a new .asp file called "details.asp". Format it however you want it to be organized. Mine is as follows:
  


On this page we need to make a new recordset connection to the database. So again, open up Window > Data Bindings and use the + sign to select Recordset (Query) from the drop down list. When it opens the new window set the following items:

Name: rsGetDetails
Connection: workshop
Table: users
Columns: ALL
Filter: ID = ID

  


You will see where this comes into play. Basically the action behind this, is that when you click a persons name from the general display name it will pass their unique ID to the details page. Then the details page reads that ID and displays ONLY the information for that person. It’s an easy thing to do, it just takes some understanding and practice.

Go back to the "displayrecords.asp" page. Now we are going to make the names a link that will take them to the details page. On the page highlight {rsGetRecords.first} and link it to the " details.asp?ID= "page. Ok this is great, but it’s not passing any information to the details page. Let’s fix this.

Open up and view the actual HTML code and scroll down to where your link for the first name is. You will see the first name display code that looks like this:

<%=(rsGetRecords.Fields.Item("first").Value)%>

Copy that code and paste it into the link after the = (equals) sign and replace out ("first") with ("ID").

So now your entire link should look like this:

<a href="details.asp?ID=<%=(rsGetRecords.Fields.Item("ID").Value)%>"><%=(rsGetRecords.Fields.Item("first").Value)%></a>

Now if you test the displayrecords.asp page you’ll see each persons name to be a link. The IMPORTANT thing is that when you roll over there names and look at the status bar you will see it passing a unique ID number for each person:

  


It is now the responsibility of the "details.asp" page to pick up that number and display the information unique to that number. This is where the step we did earlier about the filter comes into play.

Filter: ID = (URL Parameter) ID
  


  




© Copyright 1999-2001/ USA America Inc.All rights reserved. Last updated --  Read our Privacy Policy

  
Webmaster & Submissions:
Contact Administration

Site Advertising:
Rates and Information


» Get tutorial template
» Virtual-FX Team




 

Download the buttons
Join our mailing list!
Enter your Email address below, then click the 'Join List' button: 

Subscribe Unsubscribe
Powered by ListBot