Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyword search display problem 1

Status
Not open for further replies.

evillin

Technical User
Jan 2, 2004
20
GB
I've created a keyword search which displays a list of names as hyperlinks - clicking a name takes the user to a second page with details about that name e.g. phone number, email, fax etc. It's paginated also - showing 10 records at a time.

The error shows the following part of my code as the problem

Response.write "<a href= "searchresult2.asp?ID=<% =objRS("ID")%>" >" <% =objRS("FamilyName") %> "</a>"

Very grateful if anyone can spot a problem with this as i've spent two days and got nowhere! Many thanks for your time...

FULL CODE

<%
DIM mySQL,objRS,detail
detail=Request.querystring("nameinput")
detail=Trim(Request("detail"))
mySQL="SELECT ID, FamilyName, DeptName, Department, PostTitle, PersonalTelephoneNumber, OtherPhone" & _
"FROM table " & _
"WHERE FamilyName LIKE '%" & Request.querystring("nameinput") & "%' OR DeptName LIKE '%" & Request.querystring("nameinput") & "%' OR Department LIKE '%" & Request.querystring("nameinput") & "%'"


Set objConn = Server.CreateObject("ADODB.Connection")

objConn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=path\DB.mdb"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorType = 1
objRS.Open mySQL, objConn

DIM intPageRecords, intRecords, intRecordCount, intCurrentPage
DIM intNumberOfPages, intDisplayPage
intPageRecords = Request.Querystring("page")
IF intPageRecords = "" THEN intPageRecords = 1 : intRecords = 1
intRecords = intPageRecords
intPageRecords = ((intPageRecords - 1) * 10) +1
intRecordCount = 0



if objRS.recordcount = 0 then
response.redirect("noresults.asp")
end if

if Not objRS.Eof then
objRS.Move (intPageRecords - 1)
Response.Write ("<hr width='90%' align='left'>")
DO WHILE intRecordCount < 10 and NOT objRS.EOF

Response.write "<a href= "searchresult2.asp?ID=<% =objRS("ID")%>" >" <% =objRS("FamilyName") %> "</a>"
Response.write "<br>"



objRS.movenext
intRecordCount = intRecordCount +1
Loop
END IF
Response.Write ("<hr width='90%' align='left'>")
%>
<%=intPageRecords%> - <%=intPageRecords+(intRecordCount-1)%> of <%=(objRS.RecordCount)%> entries
<p>Entries
<%
intCurrentPage = Request.Querystring("page")
IF intCurrentPage = "" THEN intCurrentPage = 1
intNumberOfPages = int(objRS.RecordCount \ 10)
IF objRS.RecordCount MOD 10<> 0 THEN intNumberOfPages = intNumberOfPages + 1
Response.Write("Pages: [")
FOR intDisplayPage = 1 TO intNumberOfPages
IF Cint(intDisplayPage) = Cint(intCurrentPage) THEN
Response.Write " <b>" & intDisplayPage & "</b> "
ELSE
Response.Write " <a href=""searchresultb.asp?nameinput="&Request.querystring("nameinput")& "&page=" & intDisplayPage & """>" & intDisplayPage &_
"</a> "
END IF
NEXT
Response.Write ("]")
Response.write "<br>"
Response.write "<br>"
Response.write "<a href=NAME.asp>" & "Back to Search Page" & "</a>"

%>
 
No need to write script tags within reposne.write:
Code:
Response.write  "<a href= "searchresult2.asp?ID=" & objRS("ID") & " >" & objRS("FamilyName") & "</a>"

;-)

[blue]An eye for an eye only leaves the whole world blind. - "Mahatma" Mohandas K. Gandhi[/blue]
 
Thanks - doh! - can't believe i missed that - however still a problem after i have corrected this - error is as below - very grateful for any thoughts...

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/phone/searchresultb.asp, line 132

Response.write "<a href= "searchresult2.asp?ID=" & objRS("ID") & " >" & objRS("FamilyName") & "</a>"
---------------------------^
 
Cause by your quotes...
Try using chr(34) instead of double quotes:
Code:
Response.Write "<a href=" & chr(34) & "searchresults2.asp?ID=" & objRS("ID") & chr(34) & ">" & objRS("FamilyName") & "</a>"

[blue]An eye for an eye only leaves the whole world blind. - "Mahatma" Mohandas K. Gandhi[/blue]
 
Success!!! Thank you very much for your help :)
 
Glad to help.
Thanks for the star!
:eek:)
Have a good start into 2005!
Andy

[blue]An eye for an eye only leaves the whole world blind. - "Mahatma" Mohandas K. Gandhi[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top