Linking search results

Results 1 to 2 of 2

Thread: Linking search results

  1. #1
    Bill Again Guest

    Default Linking search results

    I have retrieved x amount of records and x amount of fields from a sql statement.<BR>One of the field names is first_name. I want to have the returned value in a hyperlink that will send selected name(record details) to a template.asp and display all the fields from that particular record.<BR>How can I do this.<BR>I know its a bit mutch to ask in one chunk so could anybody supply info as to the whereabouts of an example that will clear this up for me.<BR>Thanks again in advance<BR>Bill

  2. #2
    Join Date
    Dec 1969

    Default RE: Linking search results

    This one is pretty easy:<BR><BR>&#060;A HREF="template.asp?name=&#060;% = Server.URLEncode(RS("first_name")) %&#062;" &#062;&#060;% = RS("first_name") %&#062;&#060;/A&#062;<BR><BR>The call to Server.URLEncode is only necessary to ensure that no illegal characters (including space!) end up in the URL.<BR><BR>So if a given record in your recordset has a field named "first_name" and that name is "William (Bill)", for example, it will still get sent to the next page correctly. And for simple names (such as "Bill") you will end up with this (if you do a "View &#124 Source" in the browser, which you should *always* do to confirm that your ASP code is generating the HTML that you expect it to!):<BR><BR>&#060;A HREF="template.asp?name=Bill"&#062;Bill&#060;/A&#062;<BR><BR>And now, in your "template.asp" page, you simply do<BR><BR>&#060;%<BR>theName = Request.QueryString("name")<BR>... make the DB connection ...<BR>Set RS = theConnection.Execute("SELECT * FROM table WHERE first_name=&#039" & theName & "&#039")<BR>... and now all the fields of the record that corresponds to ...<BR>... the given first_name will be sitting there in RS, ready to use...<BR>%&#062;<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