Turn a Query value into a hyperlink

Results 1 to 3 of 3

Thread: Turn a Query value into a hyperlink

  1. #1
    Join Date
    Dec 1969

    Default Turn a Query value into a hyperlink

    I have setup a query that returns a list of current topics in a SQL database. I would like for the user to be able to click on a topic, and another query would be run. How can I assign a hyperlink to a return value from a query? The hyperlink would point to the same ASP page, it would just pass the value that the user clicked on, which would be dynamic based on the values in the database. Has anyone done this before? Any help would be greatly appreciated, thanks.<BR><BR>Duff

  2. #2
    Join Date
    Dec 1969

    Default One of the most fundamental uses...

    ...of a DB with ASP, et al. If you don&#039;t have a book on ASP, it&#039;s past time to get one, yes?<BR><BR>&#060;%<BR>...<BR>If "" & Request("topic") = "" Then<BR> SQL = "SELECT topic FROM topics"<BR> Set RS = yourConnection.Execute( SQL )<BR> Do Until RS.EOF<BR>%&#062;<BR> &#060;A HREF="thisSamePage.asp?topic=&#060;%=Escape(RS("to pic"))%&#062;" &#062; &#060;%=RS("topic")%&#062; &#060;/A&#062;<BR>&#060;%<BR> RS.MoveNext<BR> Loop<BR> RS.Close<BR><BR>Else<BR> &#039; *did* get a topic in the querystring:<BR> SQL = "SELECT * FROM topics WHERE topic = &#039;" & Request("topic") & "&#039;"<BR> Set RS = yourConnection.Execute( SQL )<BR> If RS.EOF Then<BR> Response.Write "??? " & Request("topic") & " not found? Why?"<BR> Response.End<BR> End If<BR>%&#062;<BR> ... display the info about that topic here ...<BR>&#060;%<BR> RS.Close<BR>End If<BR>...<BR>%&#062;<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: One of the most fundamental uses...

    (you should always listen to what bill says. especially when it&#039;s in the same thread where i contribute some kind of input.)<BR><BR>here is some code i put together to accomplish a similar goal.<BR><BR>i wanted to display records in an i-frame.<BR><BR>i created "column headers" (ie., Name, Dept, Ext) and then placed an i-frame directly below the "headers".<BR><BR>i fed the i-frame a SELECT statement in one of two ways........1. via a search form the user could submit to search for records by name, dept, or ext. OR 2. via a querystring sent when the user clicked one of the "headers"<BR><BR>when one of these two events occured (search form submittal OR sort link click), the i-frame page would be refreshed.<BR><BR>the challenge i found was this:<BR><BR>after a user would submit a search to trim down the size of the list they were looking at (by default ALL records are listed in the display panel), they would left with, say, 15 records out of 215 possible records.<BR><BR>well, if the user clicks the sort links, the i-frame page was being sent a SELECT that returned the ENTIRE list of records sorted as specified.<BR><BR>i had to figure out how to save the preserve the records searched for and still allow for sorting.<BR><BR>it was fun figuring it out. it didn&#039;t take that long. it&#039;s probably very sloppy, but it works.<BR><BR>here&#039;s part of the i-frame page:<BR><BR><BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;%<BR>dim objConn, objRS, strSQL, searchtype, entry, sort<BR>entry = Request.Form("entry")<BR>searchtype = Request.Form("searchtype")<BR>sort = Request.QueryString("sql")<BR>if sort+""="" then<BR> strSQL = "SELECT * FROM Driver, Car WHERE Driver.DriverID=Car.DriverID ORDER BY Last"<BR>else<BR> strSQL = "SELECT * FROM Driver, Car WHERE Driver.DriverID=Car.DriverID ORDER BY "&sort<BR>end if<BR>if not searchtype+""="" then<BR> Session("Checker")=1<BR> strSQL = "SELECT * FROM Driver, Car WHERE Driver.DriverID=Car.DriverID AND "&searchtype&" LIKE &#039;%"&entry&"%&#039;"<BR> Session("Thread") = strSQL<BR>end if<BR>if Session("Checker")=1 and searchtype+""="" then<BR> strSQL = Session("Thread")&" ORDER BY "&sort<BR>end if<BR><BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR> objConn.ConnectionString = "vehicles"<BR> objConn.Open<BR> <BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR> objRS.Open strSQL, objConn, ,3<BR><BR>DISPLAY RECORDS HERE......<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts