...

View Full Version : how can i make links with data fields in db



minhas4all
09-07-2005, 09:10 AM
hello
i am newbie not only to this forum but also to ASP
i mean now trying to learn
i make a database table for news with field newsid , newsheadline and newdetails now i want to put the headline scrolling as marquee on page whcih is ok and doing well the code is


<%
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = medicalrecords; User Id = sa; Password="
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT newid, newsheadline FROM marqlink ", conn
%>
<table width="558" border="1" align="center">
<tr><td width="548">
<marquee onMouseOver="this.stop()" onMouseOut="this.start()">
<% Do While Not rs.EOF
Response.Write "<a href=""dispmdett.asp.id=" & rs(0) & """>" & rs(1) & "</a>&nbsp;&nbsp;&nbsp;"
rs.MoveNext
Loop %>
'<input name="h1" type="hidden" value="<%'request.querystring("link_id")%>">
<% rs.close
conn.close%>
</marquee></td></tr></table>

but i did not know how to make the page for news details and when ever i clik on link it take me to the specific news details
waiting for your reply
thanks in advace

glenngv
09-07-2005, 09:22 AM
The start of querystring is ? and not .

Response.Write "<a href=""dispmdett.asp?id=" & ...

minhas4all
09-07-2005, 09:28 AM
The start of querystring is ? and not .

Response.Write "<a href=""dispmdett.asp?id=" & ...
its ok i can go with ?
but my problem is how to make a page to that i can link these links

glenngv
09-07-2005, 09:53 AM
dispmdett.asp:

<html>
<head>
<title>News</title>
</head>
<body>
<%
dim id, conn, rs
id = Request.QueryString("id")
'validate id
if not isnumeric(id) then
response.write "Invalid id."
else
'...open db connection
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = medicalrecords; User Id = sa; Password="
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT newid, newsheadline, newdetails FROM marqlink WHERE newid=" & id, conn

if rs.EOF or rs.BOF then
'news not found
response.write "News not found."
else
'display news details
response.write "<h1>" & rs("newsheadline") & "</h1><p>" & rs("newdetails") & "</p>"
end if

'kill objects
rs.close
set rs=nothing
conn.close
set conn = nothing
end if
%>
</body>
</html>

minhas4all
09-07-2005, 07:36 PM
dispmdett.asp:

<html>
<head>
<title>News</title>
</head>
<body>
<%
dim id, conn, rs
id = Request.QueryString("id")
'validate id
if not isnumeric(id) then
response.write "Invalid id."
else
'...open db connection
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = medicalrecords; User Id = sa; Password="
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT newid, newsheadline, newdetails FROM marqlink WHERE newid=" & id, conn

if rs.EOF or rs.BOF then
'news not found
response.write "News not found."
else
'display news details
response.write "<h1>" & rs("newsheadline") & "</h1><p>" & rs("newdetails") & "</p>"
end if

'kill objects
rs.close
set rs=nothing
conn.close
set conn = nothing
end if
%>
</body>
</html>

thanks
your code is working well
you guys are doing well
this is my first day and i got the solution
thanks once again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum