kustomlogo  

Go Back   Kustom PC's Forums > Computers > Programming

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-08-2005, 18:01   #1
hypnotic_monkey
New Member
 
hypnotic_monkey's Avatar
 
Join Date: Aug 2005
Posts: 5
Unhappy Asp / Ado / Sql - Help!!!!


Ok, i have a question for you all.

I have listed all the data (ado/sql) in a table (asp). But i want to hyperlink each peice of data to a different page with ID. e.g.

Column1
data1 > showdata.asp?id=1
data2 > show data.asp?id=2

Column2
asd1 > showasd?id=1
asd2 > showasd?id=2

Please help me on this one.
__________________
Thanks,
Hypnotic Monkey
www.hypnoticmonkey.co.uk

Last edited by hypnotic_monkey; 08-08-2005 at 19:31.
hypnotic_monkey is offline   Reply With Quote
Old 08-08-2005, 19:15   #2
six5tring
Silent Kristian Konsumer
 
Join Date: Oct 2004
Location: Cambridge
Posts: 3,270
Send a message via MSN to six5tring
use a normal sized font dude! also 'column'. anyway, welcome. also a little more explaination would be nice.

six
__________________
Desktop: Lian Li PC777, E8400, 8gb, 2 x 500gb (raid 0), GTX260, Dell 23"
Laptop: 13" MPB
...the forum is a mess and Forthy just needs to rule it
six5tring is offline   Reply With Quote
Old 08-08-2005, 19:45   #3
hypnotic_monkey
New Member
 
hypnotic_monkey's Avatar
 
Join Date: Aug 2005
Posts: 5
Using the code:

Quote:
<!--#Include file="inc_data.asp"-->
<html>
<body>
<table border="0" align="center">
<tr>
<th>
<a href="joblist.asp?sort=id">Job ID</a>
</th>
<th>
<a href="joblist.asp?sort=emid">Employer ID</a>
</th>
<th>
<a href="joblist.asp?sort=location">Location</a>
</th>
<th>
<a href="joblist.asp?sort=title">Job Title</a>
</th>
<th>
<a href="joblist.asp?sort=type">Job Type</a>
</th>
</tr>
<%
if request.querystring("sort")<>"" then
sort=request.querystring("sort")
else
sort="id"
end if

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT id, emid, location, title, type FROM tbl_jobs ORDER BY " & sort
rs.Open sql,cString

do until rs.EOF
response.write("<tr width='100'>")
for each x in rs.Fields
response.write("<td width='100'>" & x.value & "</td>")
next
rs.MoveNext
response.write("</tr>")
loop
rs.close
%>
</table>
</body>
</html>
I want the displayed data to have a link to another page. E.G.
data displayed = 45
link to = page.asp?id=45

Like:

Quote:
<td style="padding-left: 8px; padding-right: 8px"><a href="viewid.asp?id=<%=item_id%>"><%=item_id%></a></td>
<td style="padding-left: 8px; padding-right: 8px"><a href="viewemid.asp?id=<%=item_emID%>"><%=item_emID %></a></td>
<td style="padding-left: 8px; padding-right: 8px"><%=item_location%></td>
<td style="padding-left: 8px; padding-right: 8px"><%=item_title%></td>
<td style="padding-left: 8px; padding-right: 8px"><%=item_type%></td>
__________________
Thanks,
Hypnotic Monkey
www.hypnoticmonkey.co.uk
hypnotic_monkey is offline   Reply With Quote
Old 08-08-2005, 21:32   #4
Chenks
Registered Trader
 
Chenks's Avatar
 
Join Date: Jan 2002
Location: Irvine, Ayrshire
Posts: 3,594
you wanna use

Code:
Server.CreateObject ("ADODB.Recordset")
Chenks is offline   Reply With Quote
Old 08-08-2005, 22:42   #5
hypnotic_monkey
New Member
 
hypnotic_monkey's Avatar
 
Join Date: Aug 2005
Posts: 5
Cool

I have used it.
__________________
Thanks,
Hypnotic Monkey
www.hypnoticmonkey.co.uk
hypnotic_monkey is offline   Reply With Quote
Old 08-08-2005, 23:04   #6
Clarksy
WebGuru & Programming Mod
 
Join Date: May 2003
Location: Farnborough, Hants.
Posts: 1,198
Your almost there. All you need to do is mix the two code snippets you posted by changing this part:
Code:
<%
if request.querystring("sort")<>"" then
sort=request.querystring("sort")
else
sort="id"
end if

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT id, emid, location, title, type FROM tbl_jobs ORDER BY " & sort
rs.Open sql,cString

do until rs.EOF
response.write("<tr width='100'>")
for each x in rs.Fields
response.write("<td width='100'>" & x.value & "</td>")
next
rs.MoveNext
response.write("</tr>")
loop
rs.close
%>
To this...
Code:
<%
if request.querystring("sort")<>"" then
    sort=request.querystring("sort")
else
    sort="id"
end if

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT id, emid, location, title, type FROM tbl_jobs ORDER BY " & sort
rs.Open sql,cString

while not rs.EOF
%>
<tr>
    <td style="padding-left: 8px; padding-right: 8px"><a href="viewid.asp?id=<%=rs("id")%>"><%=rs("id")%></a></td>
    <td style="padding-left: 8px; padding-right: 8px"><a href="viewemid.asp?id=<%=rs("emID")%>"><%=rs("emID")%></a></td>
    <td style="padding-left: 8px; padding-right: 8px"><%=rs("location")%></td>
    <td style="padding-left: 8px; padding-right: 8px"><%=rs("title")%></td>
    <td style="padding-left: 8px; padding-right: 8px"><%=rs("type")%></td>
</tr>
<%
rs.MoveNext
wend
rs.close
%>
Note: there are much faster ways of doing this. If your know ADO then try using the faster .getString() method to build your table without needing to loop through a recordset. This will only work if all TD's are built the same way tho'

Last edited by Clarksy; 08-08-2005 at 23:07.
Clarksy is offline   Reply With Quote
Old 08-08-2005, 23:36   #7
hypnotic_monkey
New Member
 
hypnotic_monkey's Avatar
 
Join Date: Aug 2005
Posts: 5
Thanks
__________________
Thanks,
Hypnotic Monkey
www.hypnoticmonkey.co.uk
hypnotic_monkey is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:46.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.