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

Trying to output at table of results, with a list of hyperlinks

Status
Not open for further replies.

Thanksandy

Technical User
Jan 1, 2003
1
0
0
GB
I am building an website that is linked to a MS Access database for a music company.
They have asked me to create a page where users can search a for a list of instruments they have, using a drop down list of options taken from the Instrument Type table in my Database using the InstrumentType_ID.
I am having problems with creating the summary page that lists all those instruments the user is looking for, depending on what type they choose i.e. Electric Guitar, from the drop down list.
I want to output the results onto another page, within a table, that will list all fields as seperate columns. The name of the instrument should be a hyperlink, that will direct the user to a page with information about that instrument. Cna anyone help

 
This should be what you are after me thinks. I have adapted my code to suit what you want but you need to alter the databse location to suit.

The query needs to be passed in the URL under query i.e.

here.com?query=guitar

and the script will do the rest.

I have assumed that the name of the instrumnet is the first col in the database, if it isnt then just change the 0 to whatever col it is in, bearing in mind that the first col is always zero. this should make the page something like

.....website.com/guitar.html

and the link would just show guitar if that was the instrument, e.t.c

Its as basic as i could make it for you.
Cheers
chris
'*******************************************************
<%@language=vbscript%>
<%option explicit%>
<%
dim objRS, strSQL, I
Dim objConnection, query

'take the query out of the url
query = request(&quot;query&quot;)
I = 0

'make the SQL string
strSQL = &quot;SELECT * FROM table WHERE InstrumentType_ID='&quot; & query & &quot;'&quot;

'make your connection to the database
objConnection = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot;
objConnection = objConnection & Server.MapPath(&quot;\folders\database.mdb&quot;)

'set the Recordset object and open it up
set objRS = server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.Open strSQL, objConnection
'now you have a full, or maybe empty recordset

if ObjRS.EOF then
'there are no records!
%>
<html>
<head>
<title>test</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
Sorry no records this time
</body>
</html>
<%else ' write the page out%>
<html>
<head>
<title>test</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<TABLE border=&quot;1&quot;><%do until objRS.EOF
'put the link in here
response.write &quot;<TD><A HREF=' & objRS.fields(0).value & &quot;.html'>&quot; & objRS.fields(0).value & &quot;</A>&quot;%>

<TR><%do until I = objRS.fields.count%>
<TD><%response.write (objRS.fields(I).value)%></TD>
<%I = I + 1
loop
I = 0%>
</TR>
<%
objRS.movenext
loop%>
</TABLE>
</body>
</html>
<%End if%> 'mi casa es su casa'
]-=tty0=-[
ICQ:82621399
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top