| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Hi look at this post I made, that was just an example to show you that the like statement is messing with you.
try building up your statements using the example below Quote:
|
|
#17
|
|||
|
|||
|
Quote:
I'm now busy adding all values to make that parameter-check complete, hope it works. will make a new post within a few minutes, cause I don't know yet how to paste it in my whol script. |
|
#18
|
|||
|
|||
|
WOWWWWWW!!!!!!!!!!!!!!!!!!!!!!!!!
This is EXACTLY what I need, it works! Thanks for a million 'NoFriends' ! When project is finished, I'll e-mail you the .zip file if you want (it's all in Dutch, )I now go further with the script .. can't wait untill it's finished!! Best regards, Bart Stens By the way: where do u live in Africa? (south?) |
|
#19
|
||||
|
||||
|
Hi Bart,
Gald you got it working! I live in South Africa, in Cape Town. I would like it if you send me the whole thing when you are done. Just send me a private message when you are done, then I will now to look for a new post from you. If you don't know how to send a private msg, just click on my name. Cheers. Hoop jyt 'n baie lekker aand. ![]() |
|
#20
|
||||
|
||||
|
Hi Bart,
here is the zoek_get.asp page zoek_get.asp Code:
<%
If Request.QueryString("Nummer") = "" Then
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open Server.MapPath("Books.mdb")
Titel = replace(Request("txtTitel"), " ", "%")
Ondertitel = replace(Request("txtOndertitel"), " ", "%")
Auteur = replace(Request("txtAuteur"), " ", "%")
Jaar = replace(Request("txtJaar"), " ", "%")
Jaargang = replace(Request("txtJaargang"), " ", "%")
Uitgever = replace(Request("txtUitgever"), " ", "%")
Bijzonderheden = replace(Request("txtBijzonderheden"), " ", "%")
Set Cat = Server.CreateObject("ADODB.recordset")
Cat.Open "SELECT DISTINCT Categorie FROM Boeken WHERE Categorie LIKE '%" & Request("cmbCategorie") & "%';", Conn
'Cat.Open "SELECT Categorie FROM Boeken;", Conn
Set Counter = Server.CreateObject("ADODB.recordset")
Counter.Open "SELECT COUNT(*) AS TellerVan FROM Boeken WHERE Titel LIKE '%" & Titel & "%' and Ondertitel LIKE '%" & Ondertitel & "%' and Auteur LIKE '%" & Auteur & "%' and Jaar LIKE '%" & Jaar & "%' and Jaargang LIKE '%" & Jaargang & "%' and Uitgever LIKE '%" & Uitgever & "%' and Bijzonderheden LIKE '%" & Bijzonderheden & "' and Categorie LIKE '" & Request("cmbCategorie") & "%' and Nummer LIKE '%" & Nummer & "%';", Conn
Set Counter2 = Server.CreateObject("ADODB.recordset")
Counter2.Open "SELECT COUNT(*) AS TellerTot FROM Boeken;", Conn
%>
Er zijn <b><%Response.Write(Counter("TellerVan"))%></b> van de <b><%Response.Write(Counter2("TellerTot"))%></b> resultaten gevonden die aan uw zoekcriteria voldoen.
<br><br><br>
<table width="95%" border="0" cellpadding="0" cellspacing="0">
<%
Call Cat.MoveFirst()
While Not Cat.EOF
Set Results = Server.CreateObject("ADODB.recordset")
Dim strSql
Dim strWhere
strWhere = ""
strSql = "SELECT * FROM Boeken WHERE "
If Titel <> "" Then
strWhere = strWhere & "Titel LIKE '%" & Titel & "%' "
end if
If Ondertitel <> "" Then
if strWhere = "" then
strWhere = strWhere & "Ondertitel LIKE '%" & Ondertitel & "%' "
else
strWhere = strWhere & "and Ondertitel LIKE '%" & Ondertitel & "%' "
end if
end if
If Auteur <> "" Then
if strWhere = "" then
strWhere = strWhere & "Auteur LIKE '%" & Auteur & "%' "
else
strWhere = strWhere & "and Auteur LIKE '%" & Auteur & "%' "
end if
end if
If Jaar <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaar LIKE '%" & Jaar & "%' "
else
strWhere = strWhere & "and Jaar LIKE '%" & Jaar & "%' "
end if
end if
If Jaargang <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaargang LIKE '%" & Jaargang & "%' "
else
strWhere = strWhere & "and Jaargang LIKE '%" & Jaargang & "%' "
end if
end if
If Uitgever <> "" Then
if strWhere = "" then
strWhere = strWhere & "Uitgever LIKE '%" & Uitgever & "%' "
else
strWhere = strWhere & "and Uitgever LIKE '%" & Uitgever & "%' "
end if
end if
If Bijzonderheden <> "" Then
if strWhere = "" then
strWhere = strWhere & "Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
else
strWhere = strWhere & "and Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
end if
end if
If Categorie <> "" Then
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Categorie & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Categorie & "%' "
end if
end if
If Nummer <> "" Then
if strWhere = "" then
strWhere = strWhere & "Nummer LIKE '%" & Nummer & "%' "
else
strWhere = strWhere & "and Nummer LIKE '%" & Nummer & "%' "
end if
end if
strSql = strSql & strWhere & ";"
Results.Open strSql, conn
Call Results.MoveFirst()
if Results("Titel") = "" then
else
%>
<tr>
<td width="306" height="2" colspan="4" bgcolor="#960000">
</td>
</tr>
<tr>
<td colspan="4" height="45" valign="bottom">
<font color="#960000"><h4><%=Results("Categorie") %></h4></font></td>
</tr>
<tr>
<td width="8%" height="20" valign="top"><font color="#888888"><b>Nr.</b></font></td>
<td width="40%" height="20" valign="top"><font color="#888888"><b>Titel</b></font></td>
<td width="32%" height="20" valign="top"><font color="#888888"><b>Ondertitel</b></font></td>
<td width="20%" height="20" valign="top"><font color="#888888"><b>Auteur</b></font></td>
</tr>
<%
While Not Results.EOF
%>
<tr>
<td width="8%" valign="top"><font color="#960000"><%=Results("Nummer")%><font color="#960000"></td>
<td width="40%" valign="top"><a href="index.asp?Pagina=boek&Nummer=<%=Results("Nummer")%>" target="_self"><%=Results("Titel")%></a><br><br></td>
<td width="32%" valign="top"><%=Results("Ondertitel")%></a><br><br></td>
<td width="20%" valign="top"><%=Results("Auteur")%></td>
</tr>
<%
Call Results.MoveNext()
Wend
%>
<tr>
<td> </td>
</tr>
<%
end if
Call Cat.MoveNext()
Wend
Results.Close
%>
</table>
<br>
Klik <a href="#" onclick="history.go(-1)" alt="Ga terug">hier</a> om terug te gaan
<br><br>
<%
Cat.Close
Counter.Close
Counter2.Close
Conn.Close
%>
<%
End If
%>
The parts in red is what I changed. zoek_form.asp Code:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open Server.MapPath("Books.mdb")
Set Rs = Server.CreateObject("ADODB.recordset")
Rs.Open "SELECT Cat FROM Categorie;", Conn
%>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<h3>Zoeken op:</h3>
<form name="zoeken" method="post" action="zoek_get.asp">
<table cellspacing="0" border="0">
<!-- >>>> ZOEKVELD VOOR Titel -->
<tr>
<td width="120">Titel:</td>
<td>
<input type="text" name="txtTitel" class="box-200" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<!-- >>>> ZOEKVELD VOOR Ondertitel -->
<tr>
<td width="120">Ondertitel :</td>
<td>
<input type="text" name="txtOndertitel" class="box-200" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<!-- >>>> ZOEKVELD VOOR Auteur-->
<tr>
<td width="120">Auteur:</td>
<td>
<input type="text" name="txtAuteur" class="box-100" maxlength="50" >
</td>
</tr>
<!-- *************************** -->
<tr><td> </td></tr>
<!-- >>>> ZOEKVELD VOOR Jaar-->
<tr>
<td width="120">Jaar:</td>
<td>
<input type="text" name="txtJaar" class="box-100" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<!-- >>>> ZOEKVELD VOOR Jaargang -->
<tr>
<td width="120">Jaargang:</td>
<td>
<input type="text" name="txtJaargang" class="box-100" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<tr><td> </td></tr>
<!-- >>>> ZOEKVELD VOOR Uitgever -->
<tr>
<td width="120">Uitgever:</td>
<td>
<input type="text" name="txtUitgever" class="box-200" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<!-- >>>> ZOEKVELD VOOR Bijzonderheden -->
<tr>
<td width="120">Bijzonderheden:</td>
<td>
<input type="text" name="txtBijzonderheden" class="box-200" maxlength="100" >
</td>
</tr>
<!-- *************************** -->
<!-- >>>> ZOEKVELD VOOR Categorie -->
<tr><td width="120">Categorie:</td>
<td>
<select name="cmbCategorie" class="box-200">
<option value=""></option>
<%
Call Rs.MoveFirst()
While Not Rs.EOF
%>
<option value="<%=Rs("Cat")%>"><%=Rs("Cat")%></option>
<%
call Rs.MoveNext()
Wend
%>
</select>
</td>
</tr>
<!-- *************************** -->
<!-- >>>> BUTTONS -->
<tr><td></td>
<td><br>
<input type="Submit" value="Zoeken" Name="btnZoeken" class="Button">
<input type="Reset" value="Wis invoer" class="button">
</td>
</tr>
<!-- *************************** -->
</table>
</form>
<!-- Form stop hier -->
<!-- Begin VBScript -->
<!--
<script language="VBScript">
<!--
Sub btnZoeken_OnClick()
if (document.zoeken.txtTitel.Value = "") AND (document.zoeken.txtOndertitel.Value = "") AND _
(document.zoeken.txtAuteur.Value = "") AND (document.zoeken.txtJaar.Value = "") AND _
(document.zoeken.txtJaargang.Value = "") AND (document.zoeken.txtUitgever.Value = "") AND _
(document.zoeken.txtBijzonderheden.Value = "") AND (document.zoeken.cmbCategorie.Value = "" ) Then
MsgBox "U heeft niets ingevuld!"
else
MsgBox "Er is een fout opgetreden, probeer het opnieuw!"
end if
end Sub
-->
<!-- </script> -->
hope this sorts out your problem. Another thing, if you don't select a category, it loops the same title for all the categories, think you should change that. Njoy! Let me know if there is any other snags. Kind Regards noFriends |
|
#21
|
|||
|
|||
|
Hi nofriends,
Ow, I just see that I didn't included RemoveHTML.asp in the .zip-file. Were you than able to open my website? (UPDATES attached to sent email) Plz. run my website by index.asp and you can click on left buttons which activate the search-script with a value, but don't seem to get a result as some of those links only post the value cmbCategorie.. (click on buttons BOEKEN, PLAATJESALBUMS, REVUE DER SPORTEN) In the url you can see that only cmbCategorie is sent, and the *counter-part* of the zoek_get.asp DOES count the correct number of records, but those records won't be shown below. HOW is that possible? I've checked the whol script, but the part for which my topic actually started, the emtpy-field *replacer* code? how to implement that for now? Regards, Bart |
|
#22
|
||||
|
||||
|
hi,
I could not open you whole site. only the stuff in the bkp folder, can you send me the whole site again please. |
|
#23
|
||||
|
||||
|
Hi Bart,
Download the attached zip file(email), the whole site is in there. It should work fine now, I changed the query at the top, and changed Code:
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Cat("Categorie") & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Cat("Categorie") & "%' "
end if
Cat("Categorie") --> this is the category passed from the zoek_form.asp page. Let me know if you need any more help. |
|
#24
|
||||
|
||||
|
Hi Bart,
here is the code for zoek_get.asp it should work fine now Code:
<%
If Request.QueryString("Nummer") = "" Then
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.Open Server.MapPath("Books.mdb")
Titel = replace(Request("txtTitel"), " ", "%")
Ondertitel = replace(Request("txtOndertitel"), " ", "%")
Auteur = replace(Request("txtAuteur"), " ", "%")
Jaar = replace(Request("txtJaar"), " ", "%")
Jaargang = replace(Request("txtJaargang"), " ", "%")
Uitgever = replace(Request("txtUitgever"), " ", "%")
Bijzonderheden = replace(Request("txtBijzonderheden"), " ", "%")
Set Counter = Server.CreateObject("ADODB.recordset")
'-----------------------------
Dim strSql
Dim strWhere
strWhere = ""
strSql = "SELECT COUNT (*) AS TellerVan FROM Boeken WHERE "
If Titel <> "" Then
strWhere = strWhere & "Titel LIKE '%" & Titel & "%' "
end if
If Ondertitel <> "" Then
if strWhere = "" then
strWhere = strWhere & "Ondertitel LIKE '%" & Ondertitel & "%' "
else
strWhere = strWhere & "and Ondertitel LIKE '%" & Ondertitel & "%' "
end if
end if
If Auteur <> "" Then
if strWhere = "" then
strWhere = strWhere & "Auteur LIKE '%" & Auteur & "%' "
else
strWhere = strWhere & "and Auteur LIKE '%" & Auteur & "%' "
end if
end if
If Jaar <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaar LIKE '%" & Jaar & "%' "
else
strWhere = strWhere & "and Jaar LIKE '%" & Jaar & "%' "
end if
end if
If Jaargang <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaargang LIKE '%" & Jaargang & "%' "
else
strWhere = strWhere & "and Jaargang LIKE '%" & Jaargang & "%' "
end if
end if
If Uitgever <> "" Then
if strWhere = "" then
strWhere = strWhere & "Uitgever LIKE '%" & Uitgever & "%' "
else
strWhere = strWhere & "and Uitgever LIKE '%" & Uitgever & "%' "
end if
end if
If Bijzonderheden <> "" Then
if strWhere = "" then
strWhere = strWhere & "Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
else
strWhere = strWhere & "and Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
end if
end if
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Cat("Categorie") & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Cat("Categorie") & "%' "
end if
If Nummer <> "" Then
if strWhere = "" then
strWhere = strWhere & "Nummer LIKE '%" & Nummer & "%' "
else
strWhere = strWhere & "and Nummer LIKE '%" & Nummer & "%' "
end if
end if
strSql = strSql & strWhere & ";"
'-----------------------------
Counter.Open strSql, conn
'"SELECT COUNT(*) AS TellerVan FROM Boeken WHERE Titel LIKE '%" & Titel & "%' and Ondertitel LIKE '%" & Ondertitel & "%' and Auteur LIKE '%" & Auteur & "%' and Jaar LIKE '%" & Jaar & "%' and Jaargang LIKE '%" & Jaargang & "%' and Uitgever LIKE '%" & Uitgever & "%' and Bijzonderheden LIKE '%" & Bijzonderheden & "' and Categorie LIKE '" & Request("cmbCategorie") & "%' and Nummer LIKE '%" & Nummer & "%';", Conn
Set Counter2 = Server.CreateObject("ADODB.recordset")
Counter2.Open "SELECT COUNT (*) AS TellerTot FROM Boeken;", Conn
%>
Er zijn <b><%Response.Write(Counter("TellerVan"))%></b> van de <b><%Response.Write(Counter2("TellerTot"))%></b> resultaten gevonden die aan uw zoekcriteria voldoen.
<br><br><br>
<table width="95%" border="0" cellpadding="0" cellspacing="0">
<%
Set Results = Server.CreateObject("ADODB.recordset")
'Dim strSql
'Dim strWhere
strWhere = ""
strSql = "SELECT * FROM Boeken WHERE "
If Titel <> "" Then
strWhere = strWhere & "Titel LIKE '%" & Titel & "%' "
end if
If Ondertitel <> "" Then
if strWhere = "" then
strWhere = strWhere & "Ondertitel LIKE '%" & Ondertitel & "%' "
else
strWhere = strWhere & "and Ondertitel LIKE '%" & Ondertitel & "%' "
end if
end if
If Auteur <> "" Then
if strWhere = "" then
strWhere = strWhere & "Auteur LIKE '%" & Auteur & "%' "
else
strWhere = strWhere & "and Auteur LIKE '%" & Auteur & "%' "
end if
end if
If Jaar <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaar LIKE '%" & Jaar & "%' "
else
strWhere = strWhere & "and Jaar LIKE '%" & Jaar & "%' "
end if
end if
If Jaargang <> "" Then
if strWhere = "" then
strWhere = strWhere & "Jaargang LIKE '%" & Jaargang & "%' "
else
strWhere = strWhere & "and Jaargang LIKE '%" & Jaargang & "%' "
end if
end if
If Uitgever <> "" Then
if strWhere = "" then
strWhere = strWhere & "Uitgever LIKE '%" & Uitgever & "%' "
else
strWhere = strWhere & "and Uitgever LIKE '%" & Uitgever & "%' "
end if
end if
If Bijzonderheden <> "" Then
if strWhere = "" then
strWhere = strWhere & "Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
else
strWhere = strWhere & "and Bijzonderheden LIKE '%" & Bijzonderheden & "%' "
end if
end if
if Request("cmbCategorie") <> "" then '-->
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Cat("Categorie") & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Cat("Categorie") & "%' "
end if
end if '-->
If Nummer <> "" Then
if strWhere = "" then
strWhere = strWhere & "Nummer LIKE '%" & Nummer & "%' "
else
strWhere = strWhere & "and Nummer LIKE '%" & Nummer & "%' "
end if
end if
strSql = strSql & strWhere & ";"
Results.Open strSql, conn
%>
<tr>
<td width="306" height="2" colspan="4" bgcolor="#960000">
</td>
</tr>
<tr>
<td colspan="4" height="45" valign="bottom">
<font color="#960000"><h4><%=Results("Categorie") %></h4></font></td>
</tr>
<tr>
<td width="8%" height="20" valign="top"><font color="#888888"><b>Nr.</b></font></td>
<% if Results("Categorie") = "Revue der Sporten" OR Results("Categorie") = "Sport in Beeld" OR Results("Categorie") = "plaatjesalbums" then %>
<td width="40%" height="20" valign="top"><font color="#888888"><b>Album</b></font></td>
<% else %>
<td width="40%" height="20" valign="top"><font color="#888888"><b>Titel</b></font></td>
<% end if %>
<% if Results("Categorie") = "Revue der Sporten" OR Results("Categorie") = "Sport in Beeld" OR Results("Categorie") = "tijdschriften" then %>
<td width="32%" height="20" valign="top"><font color="#888888"><b>Jaargang</b></font></td>
<% Elseif Results("Categorie") = "plaatjesalbums" then %>
<td width="32%" height="20" valign="top"><font color="#888888"><b>Serie</b></font></td>
<% Elseif Results("Categorie") <> "" then %>
<td width="32%" height="20" valign="top"><font color="#888888"><b>Ondertitel</b></font></td>
<% end if %>
<% if Results("Categorie") = "tijdschriften" then %>
<td width="20%" height="20" valign="top"><font color="#888888"><b>Nummer</b></font></td>
<% Elseif Results("Categorie") = "Revue der Sporten" OR Results("Categorie") = "Sport in Beeld" then %>
<td width="20%" height="20" valign="top"><font color="#888888"><b>Uitgever</b></font></td>
<% Elseif Results("Categorie") = "plaatjesalbums" then %>
<td width="20%" height="20" valign="top"><font color="#888888"><b>Plaatjes</b></font></td>
<% Elseif Results("Categorie") <> "" then %>
<td width="20%" height="20" valign="top"><font color="#888888"><b>Auteur</b></font></td>
<% end if %>
<%
While Not Results.EOF
%>
<tr>
<td width="8%" valign="top"><font color="#960000"><%=Results("Nummer")%><font color="#960000"></td>
<td width="40%" valign="top"><a href="index.asp?Pagina=boek&Nummer=<%=Results("Nummer")%>" target="_self"><%=Results("Titel")%></a><br><br></td>
<% if Results("Ondertitel") <> "" then %>
<td width="32%" valign="top"><%=Results("Ondertitel")%><br><br></td>
<% else %>
<td width="32%" valign="top"><%=Results("Jaargang")%><br><br></td>
<% end if %>
<% if Results("Auteur") <> "" then %>
<td width="20%" valign="top"><%=Results("Auteur")%><br><br></td>
<% else %>
<td width="20%" valign="top"><%=Results("Druk")%><br><br></td>
<% end if %>
</tr>
<%
Call Results.MoveNext()
Wend
%>
<tr>
<td> </td>
</tr>
<%
Results.Close
%>
</table>
<br>
Klik <a href="#" onclick="history.go(-1)" alt="Ga terug">hier</a> om terug te gaan
<br><br>
<%
Counter.Close
Counter2.Close
Conn.Close
%>
<%
End If
%>
|
|
#25
|
|||
|
|||
|
Hi Jako,
Thanks for helping me with my final problem, now everything works. Tested with several search-commands, and all results match fine, and also the counter does its work nice. I also had to change two things in your script, as when I selected just a category from the box, it wouldn't give any results of that category. So I did the following: Changed these: Code:
************************************************** *******************
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Cat("Categorie") & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Cat("Categorie") & "%'
"
end if
************************************************** *******************
if Request("cmbCategorie") <> "" then '-->
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Cat("Categorie") & "%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Cat("Categorie") & "%'
"
end if
end if '-->
************************************************** *******************
Into those:
************************************************** *******************
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Request("cmbCategorie") &
"%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Request("cmbCategorie")
& "%' "
end if
************************************************** *******************
if Request("cmbCategorie") <> "" then '-->
if strWhere = "" then
strWhere = strWhere & "Categorie LIKE '%" & Request("cmbCategorie") &
"%' "
else
strWhere = strWhere & "and Categorie LIKE '%" & Request("cmbCategorie")
& "%' "
end if
end if '-->
************************************************** *******************
Best regards, Bart Stens Last edited by Shadow Wizard : January 17th, 2005 at 04:24 PM. Reason: added code tags around code - please do it yourself next. |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > <% Response.Write %> into <% Response.Write %> |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|