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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking to single record

Status
Not open for further replies.

mcpeekj

Vendor
Sep 21, 2001
105
Now I'm cookin. I've got my inventory page searchable and sortable on the fly. Next step is to allow the user to click on a text link "Details" and go to the individual record in the db. There is an ID affiliated with each vehicle which I am assuming will be used. I guess my question is: how do I attach that id to the text link so that I can post it in the URL to be read by the viewDetails.asp page. Once it is there, I can pull it out just fine, it's just a matter of getting there.
I appreciate the help.
 
do something like this:

<a href=&quot;viewDetails.asp?id=<%=ID%>&quot;>Click here for details</a>

where ID is a variable that holds the id of the individual records. You can replace the variable with a recordset call as well:

<a href=&quot;viewDetails.asp?id=<%=rs.fields(&quot;ID&quot;)%>&quot;>Click here for details</a>
 
in your list/search result don't just put the item/product name but add their ID with a link such as

while not rs.eof
response.write &quot;<LI><a href=viewDetail.asp?item=&quot; & rs.fields(&quot;itemID&quot;) & &quot;>&quot; & rs.fields(&quot;itemName&quot;) & &quot;</A>&quot;
rs.movenext
wend
 
SAWEET! Thank you both. Worked like a charm
 
a star to them = thanks ;) www.vzio.com
star.gif

star.gif
 
ok, maybe i don't have this figured out. when i try to pull up the info, all it does is pull up the first record in the db. how can i make that relate to the id?
 
I don't understand your question... could you restate and maybe post the code that you are having trouble with?
 
if request.querystring(&quot;itemID&quot;)<>&quot;&quot; then ' Show detail
set rs = conn.execute(&quot;select itemID, itemName from tbl_items WHERE ITEMID = &quot; & REQUEST.QUERYSTRING(&quot;ItemID&quot;))
data = rs.getrows
list_data(data)
else ' List All
set rs = conn.execute(&quot;select itemID, itemName from tbl_items&quot;)

while not rs.eof
response.write &quot;<LI><a href=viewDetail.asp?item=&quot; & rs.fields(&quot;itemID&quot;) & &quot;>&quot; & rs.fields(&quot;itemName&quot;) & &quot;</A>&quot;
rs.movenext
wend
end if

I hope this helps.
 
i have vehicles in a db. all have an id #. after clicking on the details link on the inventory listing page, the viewDetails.asp page comes up and shows the rest of the info for that vehicle. the code for viewDetails.asp is below...

i guess it makes sense that it's not pulling the info from the individual id since there's nothing there to tell it to do so.

<% Option Explicit %>
<div id=&quot;content&quot; style=&quot;position:absolute; left:155px; top:97px; width:612px; height:263px; z-index:3; visibility: visible&quot;>
<%
Dim ID
' Putting the values of ADO constants
Const adCmdTableDirect = &H0200
Const adLockReadOnly = 1
Const adOpenStatic = 1
Const adUseClient = 3
Dim SortBy
ID = CStr(Request(&quot;ID&quot;))
Dim connStr
connStr = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & _
Server.MapPath(&quot;inventory.mdb&quot;)
Dim rs
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.CursorLocation = adUseClient
rs.Open &quot;tblInventory&quot;, connStr, adOpenStatic, adLockReadOnly, adCmdTableDirect
Response.Write &quot;<table width=200 border=0 cellpadding=0 cellspacing=0&quot; & vbcrlf
Response.Write &quot;<tr>&quot;
Response.Write &quot;<td width=150>&quot;
Response.Write &quot;Inventory ID&quot;
Response.Write &quot;</td><td width=75>&quot;
Response.Write ID
Response.Write &quot;</td></tr><tr><td width=75>&quot;
Response.Write &quot;Year&quot;
Response.Write &quot;</td><td width=75>&quot;
Response.Write rs(&quot;Year&quot;)
Response.Write &quot;</td></tr><tr><td width=75>&quot;
Response.Write &quot;Make&quot;
Response.Write &quot;</td><td width=75>&quot;
Response.Write rs(&quot;Make&quot;)
Response.Write &quot;</td></tr><tr><td width=75>&quot;
Response.Write &quot;Model&quot;
Response.Write &quot;</td><td width=75>&quot;
Response.Write rs(&quot;Model&quot;)
Response.Write &quot;</td></tr><tr><td width=75>&quot;
Response.Write &quot;</td></tr></table>&quot;
rs.Close
Set rs = Nothing
%>

any ideas?
i'm also going to need to pull a picture of each vehicle from the db. is that done with the same rs(&quot;title&quot;) tag?
 
Try this to get the one record you are looking for:

Dim SQL
'set the SQL string to what you want to get
SQL = &quot;SELECT * FROM tblInventory WHERE ID=&quot; & ID
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.CursorLocation = adUseClient
'execute the SQL string
rs.Open SQL, connStr, adOpenStatic, adLockReadOnly
 
you work magic juanitaC. can you help me get an image out of my db also? after that, i'll all worked out and will never bother you again. thanks
 
Is the image itself in your database, or just a path to the image?

If it is the first, I can't help you - outside my realm of experience. If it is the second, you just need to do something like this:

<img src=&quot;<%=rs.fields(&quot;Column_That_Stores_Image_Path&quot;)%>&quot;>

Just make sure that the path you store is in url format: ie) &quot;not &quot;c:\\image_folder\imagename.type&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top