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

Please can somebody help. I want to

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
Please can somebody help. I want to create a form by where there is a drop down box (each selection corresponds with the field in a table in MS Access) and a text entry fiels to enter additional search criteria. This is my code...

<%
view = request.querystring(&quot;view&quot;)

' set up database conection
' this connection does not require an ODBC reference
path = Trim(Server.MapPath(&quot;/fpdb&quot;))
conn_string = &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; + path + &quot;\images.mdb&quot;
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
con.open conn_string

if view = &quot;post&quot; then
text = &quot;reference goes here&quot;

end if
%>
<html>

<head>
<%
if view=&quot;upload&quot; then
response.write(&quot;<meta http-equiv='refresh' content='4; url=images.asp?view=read'>&quot;)
end if
%>

<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>


<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>

</SCRIPT>
<title></title>
</head>

<body vlink=&quot;#0000FF&quot; alink=&quot;#0000FF&quot;>

<p align=&quot;center&quot;><b><a href=&quot;../image%20database/IMAGE%20Scan.asp?view=read&quot;><img border=&quot;0&quot; src=&quot;../image%20database/imagedb.jpg&quot;></a></b></p>

<p align=&quot;center&quot;>&nbsp;</p>

<%
if view= &quot;read&quot; then
search = request.querystring(&quot;filter&quot;)

' ------- if no filter show all records
if search=&quot;&quot; then
mode=&quot;full&quot;
mySQL = &quot;SELECT top 100 * FROM pic_table ORDER BY id desc;&quot;

' ----- if filter set to specific words then special SQL applies
elseif search=&quot;PRESETSEARCH_TOP200&quot; then
mode=&quot;filtered&quot;
mySQL = &quot;SELECT top 200 * FROM pic_table ORDER BY id desc;&quot;
elseif search=&quot;PRESETSEARCH_TOP350&quot; then
mode=&quot;filtered&quot;
mySQL = &quot;SELECT top 350 * FROM pic_table ORDER BY id desc ;&quot;
elseif search=&quot;PRESETSEARCH_TOP500&quot; then
mode=&quot;filtered&quot;
mySQL = &quot;SELECT top 500 * FROM pic_table ORDER BY id desc;&quot;
else
' ------- show filtered recordset only
search=&quot;%&quot;+search+&quot;%&quot;
mode=&quot;filtered&quot;
mySQL = &quot;SELECT * FROM pic_table where cadastre like &quot; & chr(39) &cstr(search) & chr(39)&&quot; or id like &quot; & chr(39) &cstr(search) & chr(39)&&quot; or details like &quot; & chr(39) &cstr(search) & chr(39) &&quot; or keywords like &quot; & chr(39) &cstr(search) & chr(39)&&quot; or author like &quot; & chr(39) &cstr(search) & chr(39)&&quot; ORDER BY id desc;&quot;
end if

sql1 = &quot;SELECT DISTINCT id,cadastre,author,details,keywords FROM [pic_table] where&quot;

if field=&quot;id&quot; then
sql2=&quot; [pic_table].&quot; & cstr(field) & &quot; = &quot; & cstr(data)
elseif field=&quot;cadastre&quot; then
sql2=&quot; [pic_table].[cadastre] like '%&quot;& cstr(data)& &quot;%'&quot;
elseif field=&quot;author&quot; then
sql2=&quot; [pic_table].[author] like '%&quot;& cstr(data)& &quot;%'&quot;
elseif field=&quot;details&quot; then
sql2=&quot; [pic_table].[details] like '%&quot;& cstr(data)& &quot;%'&quot;
elseif field=&quot;details&quot; then
sql2=&quot; [pic_table].[details] like '%&quot;& cstr(data)& &quot;%'&quot;
else
sql2=&quot; [pic_table].&quot; & cstr(field) & &quot; like '&quot; & cstr(data) & &quot;%'&quot;
end if

sql3=&quot; Order by [Cadastre];&quot;

sql = sql1 & sql2 & sql3

Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open mySQL, con, 0, 1
%>

<hr>
<p align=&quot;center&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#800000&quot;>Options:&nbsp;&nbsp;</font><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b><a href=&quot;../image%20database/IMAGE%20Scan.asp?view=read&quot;>Image
Quick Scan</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=&quot;for a Reference</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=&quot;the database</a></b></font>

<hr>
<p align=&quot;center&quot;>&nbsp;&nbsp;<%if mode=&quot;filtered&quot; then%>
<font face=&quot;Tahoma&quot; size=&quot;2&quot;><a href=&quot;../image%20database/IMAGE%20Scan.asp?view=read&quot;><img border=&quot;0&quot; src=&quot;../images/blinktriangle.gif&quot; alt=&quot;You are currently viewing a filtered list from your previous search.... click on this to return to main IMAGE DATABASE page&quot; align=&quot;left&quot;></a></font>
<P align=&quot;center&quot;> <font face=&quot;Verdana&quot; size=&quot;1&quot; color=&quot;#99A6FB&quot;>&nbsp;&nbsp;
...you are currently viewing a filtered list</font><font face=&quot;Verdana&quot; size=&quot;1&quot; color=&quot;#99A6FB&quot;>...<br>
<br>
[<a href=&quot;]&nbsp;&nbsp;&nbsp;
[<a href=&quot;../image%20database/IMAGE%20Scan.asp?view=read&quot;>QUICK SCAN</a>]<br>
</font><%end if%><br>
<%if mode<>&quot;filtered&quot; then%><font face=&quot;Verdana&quot; size=&quot;1&quot; color=&quot;#99A6FB&quot;>Showing latest
100
images uploaded...</font><%end if%>

<font color=&quot;#808080&quot; face=&quot;Arial&quot; size=&quot;3&quot;><br>
</font>

<%
do until rs.EOF
new_date=rs(&quot;posted&quot;)
%>
</P>
<div align=&quot;center&quot;>
<center>
<table width=&quot;625&quot; height=&quot;20&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;1&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; rowspan=&quot;4&quot; align=&quot;center&quot; style=&quot;border: 1 solid #99A6FB&quot;><font color=&quot;#800000&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;><a href=&quot;IMAGE_VIEW.asp?view=<%=rs(&quot;id&quot;)%>&quot;><img src=&quot;../NetVisual/thumbnails/thmb_<%=rs(&quot;piclocation&quot;)%>&quot; width=&quot;100&quot; bgcolor=&quot;#C9D5F5&quot; 24&quot; height=&quot;100&quot; alt=&quot;<%=cstr(rs(&quot;id&quot;))%>&quot; align=&quot;center&quot;></a></font></td>
<td width=&quot;295&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot;><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>Image
ID:</font><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#808080&quot;> </font><a href=&quot;IMAGE_VIEW.asp?view=<%=rs(&quot;id&quot;)%>&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#3F73ED&quot;><b><%=rs(&quot;id&quot;)%></b></font></a></font><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#3F73ED&quot;><b>&nbsp;</b></font></td>
<td width=&quot;504&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot; rowspan=&quot;2&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot; face=&quot;Verdana&quot;>Details</font><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>:</font><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#808080&quot;> </font></font><font face=&quot;Tahoma&quot; size=&quot;1&quot; color=&quot;#008000&quot;><%=rs(&quot;details&quot;)%></font><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#3F73ED&quot;><b>&nbsp;</b></font></td>
</tr>

<tr>
<td width=&quot;295&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot;><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>Cadastre:</font><font size=&quot;2&quot; face=&quot;Tahoma&quot; color=&quot;#808080&quot;>
</font><span style=&quot;text-transform: uppercase&quot;><font size=&quot;2&quot; face=&quot;Tahoma&quot; color=&quot;#008080&quot;>
<%=rs(&quot;cadastre&quot;)%></font></span></font></td>
</tr>

<tr>
<td width=&quot;295&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot;><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>Date
Uploaded:</font><font size=&quot;2&quot; face=&quot;Tahoma&quot; color=&quot;#808080&quot;> </font><font size=&quot;2&quot; face=&quot;Tahoma&quot; color=&quot;#008080&quot;> <%=rs(&quot;posted&quot;)%></font></font></td>
<td width=&quot;504&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot; rowspan=&quot;2&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot; face=&quot;Verdana&quot;>Keywords</font><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>:</font></font><font face=&quot;Tahoma&quot; size=&quot;1&quot; color=&quot;#008000&quot;><%=rs(&quot;keywords&quot;)%></font><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#3F73ED&quot;><b>&nbsp;</b></font></td>
</tr>

<tr>
<td width=&quot;295&quot; bgcolor=&quot;#FCFFF0&quot; bordercolor=&quot;#99A6FB&quot; style=&quot;border: 1 solid #99A6FB&quot;><font face=&quot;Verdana&quot;><font size=&quot;2&quot; color=&quot;#C0C0C0&quot;>User
ID:</font><font size=&quot;2&quot; color=&quot;#808080&quot;>&nbsp;</font><font size=&quot;2&quot; face=&quot;Tahoma&quot; color=&quot;#008080&quot;><%=rs(&quot;author&quot;)%></font></font></td>
</tr>

<tr>
<td width=&quot;265&quot; bgcolor=&quot;#FFFFFF&quot; bordercolor=&quot;#99A6FB&quot; align=&quot;center&quot; colspan=&quot;2&quot;>
<p align=&quot;center&quot;>&nbsp;</p>
</td>
</tr>

<%
rs.movenext
loop
rs.close
%>
</table>


</center>
</div>

<p>&nbsp;</p>

<%elseif view = &quot;filter&quot; then
%>


<div align=&quot;center&quot;>
<table border=&quot;0&quot; width=&quot;511&quot;>
<tr>
<td width=&quot;503&quot;>
<p align=&quot;center&quot;><b><font face=&quot;Tahoma&quot; color=&quot;#3F73ED&quot; size=&quot;2&quot;>Select
a category from the drop-down box and enter your search criteria...</font></b>
<center>


<form method=&quot;GET&quot; action=&quot;IMAGE.asp&quot; name=&quot;FrontPage_Form1&quot; target=&quot;_self&quot;>
<p align=&quot;center&quot;><select size=&quot;1&quot; name=&quot;D1&quot;>
<option value=&quot;Cadastre&quot; selected>Cadastre</option>
<option value=&quot;ID&quot;>ID</option>
<option value=&quot;Author&quot;>Author</option>
<option value=&quot;Details&quot;>Details</option>
<option value=&quot;Keywords&quot;>Keywords</option>
</select><input type=&quot;text&quot; name=&quot;view&quot; size=&quot;6&quot; value=&quot;read&quot; style=&quot;color: #FFFFFF; position: absolute; z-index: -3; font-family: Abadi MT Condensed; font-size: 8pt; background-color: #FFFFFF; left: 575; top: 20&quot;><input type=&quot;text&quot; name=&quot;filter&quot; size=&quot;37&quot;><input type=&quot;submit&quot; value=&quot;Search&quot; name=&quot;button1&quot;></a></p>
<p align=&quot;center&quot;>&nbsp;
</p>
<p align=&quot;center&quot;><br>
<font color=&quot;#000080&quot;>
&nbsp;<b><font size=&quot;2&quot; face=&quot;Tahoma&quot;><span style=&quot;letter-spacing: 3pt&quot;>-
Special
Searches-</span></font>
</b></font>
</p>
<p align=&quot;center&quot;><font color=&quot;#99A6FB&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;><a href=&quot;../image%20database/image%20scan.asp?view=read&filter=PRESETSEARCH_TOP200&quot;><span style=&quot;font-variant: small-caps&quot;>latest
200</span></a></font><font face=&quot;Tahoma&quot; size=&quot;2&quot;><font color=&quot;#99A6FB&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;><a href=&quot;../image%20database/image%20scan.asp?view=read&filter=PRESETSEARCH_TOP350&quot;><span style=&quot;font-variant: small-caps&quot;><br>
latest 350<br>
</span></a><a href=&quot;../image%20database/image%20scan.asp?view=read&filter=PRESETSEARCH_TOP500&quot;><span style=&quot;font-variant: small-caps&quot;>latest</span></a><span style=&quot;font-variant: small-caps&quot;><a href=&quot;../image%20database/image%20scan.asp?view=read&filter=PRESETSEARCH_TOP500&quot;>
500</a></span></font><br>
</font></p>
<p align=&quot;center&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><a href=&quot;../image%20database/IMAGE_USER.asp?view=filter&quot;>Top
100 for specific User ID</a></font></p>
<p align=&quot;center&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><a href=&quot;../image%20database/GroupSearch.htm&quot;>View
images from an Upload Group</a></font></p>
<p align=&quot;center&quot;>&nbsp;</p>
<p align=&quot;center&quot;>&nbsp;<a href=&quot;../image%20database/IMAGE%20Scan.asp?view=read&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b>Go to
Image Quick Scan</b></font></a></p>
</form>

</center>

</table>

</div>


<p>


<%
else

'error trap if nothing selected but got here by mistake - eg no view value after .asp in url
if view=&quot;&quot; then
view=&quot;0&quot;
end if

mySQL = &quot;SELECT * FROM pic_table where id=&quot;
mySQL=mySQL + cstr(view)
mySQL=mySQL + &quot; ORDER BY id desc&quot;
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open mySQL, con, 0, 1
%>

</p>


<p>


&nbsp;

</p>

<div align=&quot;center&quot;>
<center>

<table border=&quot;1&quot; width=&quot;791&quot; height=&quot;104&quot;>
<tr>
<td width=&quot;102&quot; rowspan=&quot;4&quot; height=&quot;98&quot;>
<p align=&quot;center&quot;><font color=&quot;#800000&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;><a href=&quot;IMAGE_VIEW.asp?view=<%=rs(&quot;id&quot;)%>&quot;><img src=&quot;../NetVisual/thumbnails/thmb_<%=rs(&quot;piclocation&quot;)%>&quot; width=&quot;100&quot; bgcolor=&quot;#C9D5F5&quot; 24&quot; height=&quot;100&quot; alt=&quot;<%=rs(&quot;piclocation&quot;)%>&quot;></a></font></p>
</td>
<td width=&quot;189&quot; height=&quot;16&quot;><b><font color=&quot;#808080&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;>Image
ID:</font></b></td>
<td width=&quot;333&quot; height=&quot;16&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><font color=&quot;#808080&quot;>&nbsp;</font><font color=&quot;#000080&quot;><%=rs(&quot;id&quot;)%></font></font></td>
<td width=&quot;97&quot; height=&quot;80&quot; rowspan=&quot;4&quot;></td>
<td width=&quot;151&quot; height=&quot;35&quot; rowspan=&quot;2&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b><font color=&quot;#808080&quot;>Details:</font></b></font></td>
<td width=&quot;1518&quot; height=&quot;35&quot; rowspan=&quot;2&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><font color=&quot;#808080&quot;><b>&nbsp;</b></font><font color=&quot;#000080&quot;><%=rs(&quot;details&quot;)%></font></font></td>
</tr>
<tr>
<td width=&quot;189&quot; height=&quot;19&quot;><b><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#808080&quot;>User
ID:</font></b></td>
<td width=&quot;333&quot; height=&quot;19&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#808080&quot;>&nbsp;<%=rs(&quot;author&quot;)%></font></td>
</tr>
<tr>
<td width=&quot;189&quot; height=&quot;26&quot;><b><font size=&quot;2&quot; color=&quot;#808080&quot; face=&quot;Tahoma&quot;>Date
Uploaded:</font></b></td>
<td width=&quot;333&quot; height=&quot;26&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot; color=&quot;#808080&quot;>&nbsp;<%=rs(&quot;posted&quot;)%>
</font></td>
<td width=&quot;151&quot; height=&quot;45&quot; rowspan=&quot;2&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b><font color=&quot;#808080&quot;>Keywords:</font></b><font color=&quot;#808080&quot;><b>&nbsp;</b></font></font></td>
<td width=&quot;1518&quot; height=&quot;45&quot; rowspan=&quot;2&quot;><font color=&quot;#000080&quot; face=&quot;Tahoma&quot; size=&quot;2&quot;>&nbsp;<%=rs(&quot;keywords&quot;)%></font></td>
</tr>
<tr>
<td width=&quot;189&quot; height=&quot;19&quot;><b><font color=&quot;#808080&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;>Cadastre:</font></b></td>
<td width=&quot;333&quot; height=&quot;19&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><font color=&quot;#808080&quot;>&nbsp;</font><font color=&quot;#000080&quot;><%=rs(&quot;cadastre&quot;)%></font></font></td>
</tr>
</table>

</center>
</div>

<p align=&quot;right&quot;><font size=&quot;2&quot; color=&quot;#008080&quot;><img border=&quot;0&quot; src=&quot;../image%20database/bd10263_.gif&quot;>&nbsp;
<a href=&quot;IMAGE_EDIT.asp?view=<%=rs(&quot;id&quot;)%>&quot;>edit details</a>&nbsp;</font></p>

<p align=&quot;center&quot;>&nbsp;</p>

<p align=&quot;center&quot;>&nbsp;</p>

<p align=&quot;left&quot;><a href=&quot;IMAGE.asp?view=read&quot;><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b>Return
to contents page</b></font></a></p>

<p><font face=&quot;Tahoma&quot; size=&quot;2&quot;><b><%
end if
%></b></font></p>

</body>

The filter bit is where I'm having trouble (receiving the foem data)... when you search I would like to only search iby the field selected in the drop down menu. Please go easy on me as I'm not very experienced!

Thanks in advance,

Marcus
 
Please don't submit your post twice. This is a duplicate post to one submitted not five minutes ago. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top