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

Pass query to detail page ?

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
GB
Hi

I want to display more detail of a record by passing the id to another page which I am doing with this URL.

Code:
<A href='picture.asp?action=display&id=&quot;&rs(&quot;id&quot;)&&quot;'>

I'm having some problems with what the code should be to select the detail and display the results, below is what I have so far however this does not work

picture.asp
Code:
<%
option explicit
dim useraction
dim dsn,sql,conn,rs
dim fname,lname,tel,mobile,init,dept,id
id=request(&quot;id&quot;)
useraction=request(&quot;action&quot;)
dsn=&quot;DBQ=&quot; & Server.Mappath(&quot;../db/phone.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
set conn=server.createObject(&quot;adodb.connection&quot;)
conn.open dsn
select case useraction
case &quot;display&quot;
sql = &quot;select * from users where id=&quot;&id
set rs = conn.execute(sql)
lname=rs(&quot;lname&quot;)
fname=rs(&quot;fname&quot;)
tel=rs(&quot;tel&quot;)
mobile=rs(&quot;mobile&quot;)
init=rs(&quot;init&quot;)
dept=rs(&quot;dept&quot;)
conn.close
set conn = nothing
end


%>

TIA
Webflex
 
Hi

What sort of things are not happening? Are you getting error messages, or is it just not displaying anything?

Give us more info ...

By the way, I am assuming that

<A href='picture.asp?action=display&id=&quot;&rs(&quot;id&quot;)&&quot;'>

is actually text you are constructing and then displaying and you didn't mean

<A href='picture.asp?action=display&id=<%=&rs(&quot;id&quot;)%>'>


Derren
[The only person in the world to like Word]
 
Have you checked the querystring value ID in picture.asp is actually containing an ID ?

I say that because the way you pass it to picture.asp doesn't look correct to me.

Also try display the sql statement you are running and then physically run that on the database and see what happens.
 
OK

I've added the code below from the pages that I'm adapting from where the value ID works.

I don't need the edit / delete / update options with this new page, what I want to do is use the value ID to open a page containing more details than appear in the initial listing.

Initial Search Page

Code:
<%option explicit
dim dsn,conn,rs,sql,x
dim flag,color,useraction,element
useraction=request.querystring(&quot;action&quot;)
select case useraction
case &quot;search&quot;
	x = 0
	sql = &quot;select * from users where id>0&quot;
	dsn=&quot;DBQ=&quot; & Server.Mappath(&quot;../db/phone.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
	set conn = server.createObject(&quot;adodb.connection&quot;)
	set rs = server.createObject(&quot;adodb.recordset&quot;)
	conn.open dsn
	
	for each element in request.form

	if request.form(element)<>&quot;&quot; then
	
		select case element
			case &quot;tel&quot;
			sql=sql & &quot; and tel = '&quot;  & Request.form(element) & &quot;'&quot;
			case &quot;lname&quot;
			sql=sql & &quot; and lname like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;fname&quot;
			sql=sql & &quot; and fname like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;mobile&quot;
			sql=sql & &quot; and mobile like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;init&quot;
			sql=sql & &quot; and init like '&quot; & Request.form(element) & &quot;%'&quot;
          case &quot;dept&quot;
			sql=sql & &quot; and dept like '&quot; & Request.form(element) & &quot;%'&quot;

		end  select 
	end if
next
sql=sql & &quot; order by lname&quot;
'response.write sql'***debug
	rs.open sql,conn
	if rs.eof and rs.bof then
		response.write &quot;No Record Found&quot;
	else
		response.write &quot;<table width=620 border=0><th align=left>Last Name</th><th align=left>First name</TH>&quot;
		response.write &quot;<th align=left>Tel</TH><th align=left>Mobile</TH><th align=left>Initials</TH><th align=left>Department</TH>&quot;
		do while not rs.eof
		if flag=0 then
			flag=1
			color=&quot;#D7D7D7&quot;
		else
			flag=0
			color=&quot;#B0C4EC&quot;
		end if

		response.write &quot;<TR bgcolor=&quot;& color & &quot;><TD>&quot;
		response.write RS(&quot;lname&quot;) & &quot;</td><td>&quot; & RS(&quot;fname&quot;) & &quot;</td><td>&quot; 
		response.write RS(&quot;tel&quot;) & &quot;</td><td>&quot; & RS(&quot;mobile&quot;) & &quot;</td><td>&quot; 
		response.write RS(&quot;init&quot;) & &quot;</tr><td>&quot; & RS(&quot;dept&quot;) & &quot;</td><td>&quot;&quot;
<A href='editdel.asp?action=edit&id=&quot;&rs(&quot;id&quot;)&&quot;'>
Code:
<b>Edit</b></td><td><A href='editdel.asp?action=del&id=&quot;&rs(&quot;id&quot;)&&quot;' onclick='return rusure()'><b>Del</b></TR></TD>&quot;
		rs.movenext
		x=x+1
	loop
	
	response.write &quot;<tr><td colspan=7>Total Records : &quot; & x & &quot;</table>&quot;
	end if
end select
%>
<html>
<head>
<script>function rusure() { 

 if (confirm(&quot;Are you sure you want to delete?&quot;)) { 
return true; 
 } else { 

return false; 
 } 
} 
</script>
<style>
a:hover{color:red}
</style>
<title>tel list</title>
<LINK REL=STYLESHEET HREF=&quot;[URL unfurl="true"]http://...../style/csog.css&quot;[/URL] TYPE=&quot;text/css&quot;>
</head>

<body>

	<table border=&quot;0&quot; width=&quot;450&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot;><b><img border=&quot;0&quot; src=&quot;../IMAGES/admin.gif&quot;><br>
    <br>
    </b>
    Search<br>Clicking on search without choosing any category will retrieve all records<br><br></font></tr>
<form action=&quot;search.asp?action=search&quot; method=&quot;post&quot;>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Search by Last name:(A-Z)</font></td><td><font face=&quot;Verdana&quot;><input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Search by First name:(A-Z)</font></td><td><font face=&quot;Verdana&quot;><input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Search by Extension .:</font></td><td><font face=&quot;Verdana&quot;><input type=&quot;text&quot; name=&quot;tel&quot; size=&quot;5&quot; maxlength=&quot;5&quot;></font></tr>
		<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Search by Initials</font></td><td><font face=&quot;Verdana&quot;><input type=&quot;text&quot; name=&quot;init&quot; size=&quot;5&quot; maxlength=&quot;5&quot;></font></tr>
   <tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Search by Department</font></td><td><font face=&quot;Verdana&quot;><input type=&quot;text&quot; name=&quot;dept&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>

		<tr><td colspan=&quot;2&quot; align=&quot;center&quot;><font face=&quot;Verdana&quot;><input type=&quot;submit&quot; value=&quot;search&quot;></font></tr>
		</table>
		<!--#include file=&quot;footer.inc&quot;-->
</body>
</html>


Detail Edit/Delete etc


Code:
<%
option explicit
dim useraction
dim dsn,sql,conn,rs
dim fname,lname,tel,mobile,init,dept,id
id=request(&quot;id&quot;)
useraction=request(&quot;action&quot;)
dsn=&quot;DBQ=&quot; & Server.Mappath(&quot;../db/phone.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
set conn=server.createObject(&quot;adodb.connection&quot;)
conn.open dsn
select case useraction
case &quot;update&quot;
	id=request.form(&quot;id&quot;)
	fname=request.form(&quot;fname&quot;)
	lname=request.form(&quot;lname&quot;)
	tel=request.form(&quot;tel&quot;)
	mobile=request.form(&quot;mobile&quot;)
	init=request.form(&quot;init&quot;)
	dept=request.form(&quot;dept&quot;)
	sql = &quot;update users SET lname='&quot;&lname&&quot;',fname='&quot;&fname&&quot;',tel='&quot;&tel&&quot;',mobile='&quot;&mobile&&quot;',init='&quot;&init&&quot;',dept='&quot;&dept&&quot;' where id=&quot;&id
	'response.write sql'***debug
	conn.execute(sql)
	conn.close
	set conn = nothing
	response.redirect &quot;search.asp&quot;
case &quot;del&quot;
	sql = &quot;delete from  users where id=&quot;&id
	conn.execute(sql)
	conn.close
	set conn = nothing
	response.redirect &quot;search.asp&quot;
case &quot;edit&quot;
sql = &quot;select * from users where id=&quot;&id
set rs = conn.execute(sql)
lname=rs(&quot;lname&quot;)
fname=rs(&quot;fname&quot;)
tel=rs(&quot;tel&quot;)
mobile=rs(&quot;mobile&quot;)
init=rs(&quot;init&quot;)
dept=rs(&quot;dept&quot;)
conn.close
set conn = nothing
%>
	

<html>

<head>
<LINK REL=STYLESHEET HREF=&quot;[URL unfurl="true"]http://......../style/csog.css&quot;[/URL] TYPE=&quot;text/css&quot;>
	<title>add</title>

</head>

<body>
<table border=&quot;0&quot; width=&quot;300&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;../IMAGES/admin.gif&quot; WIDTH=&quot;150&quot; HEIGHT=&quot;40&quot;><br> <br>
    <font face=&quot;Verdana&quot; size=&quot;2&quot;>Edit Record</font><br></tr>
<form action=&quot;editdel.asp?action=update&quot; method=&quot;post&quot;>
<input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;<%=id%>&quot;>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Last name:</font></td><td><input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= lname %>&quot;></tr>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		First name:</font></td><td><input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= fname %>&quot;></tr>
	<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Tel.:</font></td><td><input type=&quot;text&quot; name=&quot;tel&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= tel %>&quot;></tr>
		<tr><td>
        Mobile</td><td><input type=&quot;text&quot; name=&quot;mobile&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= mobile %>&quot;></tr>
		<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Initials:</font></td><td><input type=&quot;text&quot; name=&quot;init&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= init %>&quot;></tr>
		<tr><td>
        <font face=&quot;Verdana&quot; size=&quot;2&quot;>
		Department:</font></td><td><input type=&quot;text&quot; name=&quot;dept&quot; size=&quot;20&quot; maxlength=&quot;20&quot; value=&quot;<%= dept %>&quot;></tr>
		<tr><td colspan=&quot;2&quot; align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;update&quot;></tr>
		</table>
<!--#include file=&quot;footer.inc&quot;-->
<%end select%>

TIA
Webflex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top