Forums
This topic is locked
conditional display question
Posted 03 May 2006 22:21:25
1
has voted
03 May 2006 22:21:25 Javier Castro posted:
This is what i have,<% If Not rsUsers.EOF Or Not rsUsers.BOF Then %>
blah blah code
<% end if %>
Can I do something like:
<% If rsUser and rsPostal and rsByCity are not EOF or Not BOF then
blah blah code
<%end if%>
if yes, can someone help me, I tried various combinations but I ad no luck.
<% If anyone can GIVE ME a Hand = True THEN %> <%=("very much appreciated"%><%end if%>
Replies
Replied 04 May 2006 02:14:31
04 May 2006 02:14:31 micah santos replied:
have you tried this?
<%
If NOT rsUser.EOF or rsUser.BOF AND rsPostal.EOF or rsPostal.BOF AND rsByCity.EOF or rsByCity.BOF Then
// ---------------------------
End If
%>
<%
If NOT rsUser.EOF or rsUser.BOF AND rsPostal.EOF or rsPostal.BOF AND rsByCity.EOF or rsByCity.BOF Then
// ---------------------------
End If
%>
Replied 04 May 2006 05:16:45
04 May 2006 05:16:45 Javier Castro replied:
Thanks Micah,
I did used your code and I got an error. Then I modified it like this:
<% If Not rsUsers.EOF Or Not rsUsers.BOF AND Not rsPostal.EOF or Not rsPostal.BOF AND Not rsByCity.EOF or Not rsByCity.BOF Then %>
blah blah
<% End If%>
and it works, but somehow it has affected my search tool Postal. it doesn't show the searches anymore. see it here: www.oel.org/bsearch.asp
So I'm going back to what I know it works.
See it here:www.oel.org/asearch.asp
What I want to do is for people not to see the Subtitle Results and the table headers. Also, to have a response.write("Query not found"
My problem Is that I do not know how to do it, I tried varios combinations but I get trapped.
Please, I need some ideas. It must be easy, that is why I cannot figure it out.
here is my code:
<pre id=code><font face=courier size=2 id=code> <%
Dim rsCity
Dim rsCity_numRows
Set rsCity = Server.CreateObject("ADODB.Recordset"
rsCity.ActiveConnection = MM_conndbcomplete_STRING
rsCity.Source = "SELECT * FROM tblCity ORDER BY cityName ASC"
rsCity.CursorType = 0
rsCity.CursorLocation = 2
rsCity.LockType = 1
rsCity.Open()
rsCity_numRows = 0
%>
<%
Dim rsChapter
Dim rsChapter_numRows
Set rsChapter = Server.CreateObject("ADODB.Recordset"
rsChapter.ActiveConnection = MM_conndbcomplete_STRING
rsChapter.Source = "SELECT * FROM tblChapters ORDER BY ChapterName ASC"
rsChapter.CursorType = 0
rsChapter.CursorLocation = 2
rsChapter.LockType = 1
rsChapter.Open()
rsChapter_numRows = 0
%>
<%
Dim rsUsers__MMColParam
rsUsers__MMColParam = "0"
If (Request.QueryString("search" <> "" Then
rsUsers__MMColParam = Request.QueryString("search"
End If
%>
<%
Dim rsUsers
Dim rsUsers_numRows
Set rsUsers = Server.CreateObject("ADODB.Recordset"
rsUsers.ActiveConnection = MM_conndbcomplete_STRING
rsUsers.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND ChapterID LIKE '" + Replace(rsUsers__MMColParam, "'", "''" + "'"
rsUsers.CursorType = 0
rsUsers.CursorLocation = 2
rsUsers.LockType = 1
rsUsers.Open()
rsUsers_numRows = 0
%>
<%
Dim rsPostal__MMColParam
rsPostal__MMColParam = "0"
If (Request.QueryString("spostal" <> "" Then
rsPostal__MMColParam = Request.QueryString("spostal"
End If
%>
<%
Dim rsPostal
Dim rsPostal_numRows
Set rsPostal = Server.CreateObject("ADODB.Recordset"
rsPostal.ActiveConnection = MM_conndbcomplete_STRING
rsPostal.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND txtPostal LIKE '" + Replace(rsPostal__MMColParam, "'", "''" + "%'"
rsPostal.CursorType = 0
rsPostal.CursorLocation = 2
rsPostal.LockType = 1
rsPostal.Open()
rsPostal_numRows = 0
%>
<%
Dim rsByCity__MMColParam
rsByCity__MMColParam = "0"
If (Request.QueryString("bycity" <> "" Then
rsByCity__MMColParam = Request.QueryString("bycity"
End If
%>
<%
Dim rsByCity
Dim rsByCity_numRows
Set rsByCity = Server.CreateObject("ADODB.Recordset"
rsByCity.ActiveConnection = MM_conndbcomplete_STRING
rsByCity.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND cityID LIKE '" + Replace(rsByCity__MMColParam, "'", "''" + "'"
rsByCity.CursorType = 0
rsByCity.CursorLocation = 2
rsByCity.LockType = 1
rsByCity.Open()
rsByCity_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsUsers_numRows = rsUsers_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = -1
Repeat2__index = 0
rsPostal_numRows = rsPostal_numRows + Repeat2__numRows
%>
<%
Dim Repeat3__numRows
Dim Repeat3__index
Repeat3__numRows = -1
Repeat3__index = 0
rsByCity_numRows = rsByCity_numRows + Repeat3__numRows
%>
<div align="left">
<p class="pageheader">Search Contractor</p>
<table border="0" align="center" cellpadding="1" cellspacing="1">
<tr valign="top">
<td><form name="form3" method="get" action="asearch.asp">
<label> By City
<select name="bycity" id="bycity">
<option value="value">Select a City</option>
<%
While (NOT rsCity.EOF)
%>
<option value="<%=(rsCity.Fields.Item("cityID".Value)%>"><%=(rsCity.Fields.Item("cityName".Value)%></option>
<%
rsCity.MoveNext()
Wend
If (rsCity.CursorType > 0) Then
rsCity.MoveFirst
Else
rsCity.Requery
End If
%>
</select>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
<tr valign="top">
<td><form name="form1" method="get" action="asearch.asp">
<label> Region
<select name="search" id="select2">
<option value="value">Select a Region</option>
<%
While (NOT rsChapter.EOF)
%>
<option value="<%=(rsChapter.Fields.Item("ChapterID".Value)%>"><%=(rsChapter.Fields.Item("ChapterName".Value)%></option>
<%
rsChapter.MoveNext()
Wend
If (rsChapter.CursorType > 0) Then
rsChapter.MoveFirst
Else
rsChapter.Requery
End If
%>
</select>
</label>
<label>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
<tr valign="top">
<td><form name="form2" method="get" action="asearch.asp">
<label>Postal
<input name="spostal" type="text" id="spostal" size="7" maxlength="7">
</label>
<label>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
</table>
<span class="newstitle">Results</span>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#DE2D3B">
<tr class="menu">
<td>Company</td>
<td><div align="center">City</div></td>
<td><div align="center">Region</div></td>
<td><div align="center">Postal</div></td>
<td><div align="center">Phone</div></td>
</tr>
<% If (rsUsers_total) = 0 Then %>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsUsers.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsUsers.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsUsers.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsUsers.MoveNext()
Wend
%>
<% End If %>
<!-- postal code -->
<% If (rsPostal_total) = 0 Then %>
<%
While ((Repeat2__numRows <> 0) AND (NOT rsPostal.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsPostal.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsPostal.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsPostal.MoveNext()
Wend
%>
<% End If %>
<!-- end postal code -->
<% If (rsByCity_total) = 0 Then %>
<%
While ((Repeat3__numRows <> 0) AND (NOT rsByCity.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsByCity.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsByCity.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat3__index=Repeat3__index+1
Repeat3__numRows=Repeat3__numRows-1
rsByCity.MoveNext()
Wend
%>
<% End If %>
</table>
<%
rsCity.Close()
Set rsCity = Nothing
%>
<%
rsChapter.Close()
Set rsChapter = Nothing
%>
<%
rsUsers.Close()
Set rsUsers = Nothing
%>
<%
rsPostal.Close()
Set rsPostal = Nothing
%>
<%
rsByCity.Close()
Set rsByCity = Nothing
%>
</font id=code></pre id=code>
I did used your code and I got an error. Then I modified it like this:
<% If Not rsUsers.EOF Or Not rsUsers.BOF AND Not rsPostal.EOF or Not rsPostal.BOF AND Not rsByCity.EOF or Not rsByCity.BOF Then %>
blah blah
<% End If%>
and it works, but somehow it has affected my search tool Postal. it doesn't show the searches anymore. see it here: www.oel.org/bsearch.asp
So I'm going back to what I know it works.
See it here:www.oel.org/asearch.asp
What I want to do is for people not to see the Subtitle Results and the table headers. Also, to have a response.write("Query not found"
My problem Is that I do not know how to do it, I tried varios combinations but I get trapped.
Please, I need some ideas. It must be easy, that is why I cannot figure it out.
here is my code:
<pre id=code><font face=courier size=2 id=code> <%
Dim rsCity
Dim rsCity_numRows
Set rsCity = Server.CreateObject("ADODB.Recordset"
rsCity.ActiveConnection = MM_conndbcomplete_STRING
rsCity.Source = "SELECT * FROM tblCity ORDER BY cityName ASC"
rsCity.CursorType = 0
rsCity.CursorLocation = 2
rsCity.LockType = 1
rsCity.Open()
rsCity_numRows = 0
%>
<%
Dim rsChapter
Dim rsChapter_numRows
Set rsChapter = Server.CreateObject("ADODB.Recordset"
rsChapter.ActiveConnection = MM_conndbcomplete_STRING
rsChapter.Source = "SELECT * FROM tblChapters ORDER BY ChapterName ASC"
rsChapter.CursorType = 0
rsChapter.CursorLocation = 2
rsChapter.LockType = 1
rsChapter.Open()
rsChapter_numRows = 0
%>
<%
Dim rsUsers__MMColParam
rsUsers__MMColParam = "0"
If (Request.QueryString("search" <> "" Then
rsUsers__MMColParam = Request.QueryString("search"
End If
%>
<%
Dim rsUsers
Dim rsUsers_numRows
Set rsUsers = Server.CreateObject("ADODB.Recordset"
rsUsers.ActiveConnection = MM_conndbcomplete_STRING
rsUsers.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND ChapterID LIKE '" + Replace(rsUsers__MMColParam, "'", "''" + "'"
rsUsers.CursorType = 0
rsUsers.CursorLocation = 2
rsUsers.LockType = 1
rsUsers.Open()
rsUsers_numRows = 0
%>
<%
Dim rsPostal__MMColParam
rsPostal__MMColParam = "0"
If (Request.QueryString("spostal" <> "" Then
rsPostal__MMColParam = Request.QueryString("spostal"
End If
%>
<%
Dim rsPostal
Dim rsPostal_numRows
Set rsPostal = Server.CreateObject("ADODB.Recordset"
rsPostal.ActiveConnection = MM_conndbcomplete_STRING
rsPostal.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND txtPostal LIKE '" + Replace(rsPostal__MMColParam, "'", "''" + "%'"
rsPostal.CursorType = 0
rsPostal.CursorLocation = 2
rsPostal.LockType = 1
rsPostal.Open()
rsPostal_numRows = 0
%>
<%
Dim rsByCity__MMColParam
rsByCity__MMColParam = "0"
If (Request.QueryString("bycity" <> "" Then
rsByCity__MMColParam = Request.QueryString("bycity"
End If
%>
<%
Dim rsByCity
Dim rsByCity_numRows
Set rsByCity = Server.CreateObject("ADODB.Recordset"
rsByCity.ActiveConnection = MM_conndbcomplete_STRING
rsByCity.Source = "SELECT intUserID, txtPhone, txtPostal, txtCompanyName, cityName, ChapterName FROM tblUsers, tblCompanies, tblCity, tblChapters WHERE intSegment = 2 AND intCompanyID = intCompID AND intCity = cityID AND intChapter = ChapterID AND cityID LIKE '" + Replace(rsByCity__MMColParam, "'", "''" + "'"
rsByCity.CursorType = 0
rsByCity.CursorLocation = 2
rsByCity.LockType = 1
rsByCity.Open()
rsByCity_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsUsers_numRows = rsUsers_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = -1
Repeat2__index = 0
rsPostal_numRows = rsPostal_numRows + Repeat2__numRows
%>
<%
Dim Repeat3__numRows
Dim Repeat3__index
Repeat3__numRows = -1
Repeat3__index = 0
rsByCity_numRows = rsByCity_numRows + Repeat3__numRows
%>
<div align="left">
<p class="pageheader">Search Contractor</p>
<table border="0" align="center" cellpadding="1" cellspacing="1">
<tr valign="top">
<td><form name="form3" method="get" action="asearch.asp">
<label> By City
<select name="bycity" id="bycity">
<option value="value">Select a City</option>
<%
While (NOT rsCity.EOF)
%>
<option value="<%=(rsCity.Fields.Item("cityID".Value)%>"><%=(rsCity.Fields.Item("cityName".Value)%></option>
<%
rsCity.MoveNext()
Wend
If (rsCity.CursorType > 0) Then
rsCity.MoveFirst
Else
rsCity.Requery
End If
%>
</select>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
<tr valign="top">
<td><form name="form1" method="get" action="asearch.asp">
<label> Region
<select name="search" id="select2">
<option value="value">Select a Region</option>
<%
While (NOT rsChapter.EOF)
%>
<option value="<%=(rsChapter.Fields.Item("ChapterID".Value)%>"><%=(rsChapter.Fields.Item("ChapterName".Value)%></option>
<%
rsChapter.MoveNext()
Wend
If (rsChapter.CursorType > 0) Then
rsChapter.MoveFirst
Else
rsChapter.Requery
End If
%>
</select>
</label>
<label>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
<tr valign="top">
<td><form name="form2" method="get" action="asearch.asp">
<label>Postal
<input name="spostal" type="text" id="spostal" size="7" maxlength="7">
</label>
<label>
<input type="submit" value="Search">
</label>
</form></td>
</tr>
</table>
<span class="newstitle">Results</span>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#DE2D3B">
<tr class="menu">
<td>Company</td>
<td><div align="center">City</div></td>
<td><div align="center">Region</div></td>
<td><div align="center">Postal</div></td>
<td><div align="center">Phone</div></td>
</tr>
<% If (rsUsers_total) = 0 Then %>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsUsers.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsUsers.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsUsers.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsUsers.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsUsers.MoveNext()
Wend
%>
<% End If %>
<!-- postal code -->
<% If (rsPostal_total) = 0 Then %>
<%
While ((Repeat2__numRows <> 0) AND (NOT rsPostal.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsPostal.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsPostal.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsPostal.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsPostal.MoveNext()
Wend
%>
<% End If %>
<!-- end postal code -->
<% If (rsByCity_total) = 0 Then %>
<%
While ((Repeat3__numRows <> 0) AND (NOT rsByCity.EOF))
%>
<tr bgcolor="#FFFFFF">
<td><%=(rsByCity.Fields.Item("txtCompanyName".Value)%></td>
<td><div align="center"><%=(rsByCity.Fields.Item("cityName".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("ChapterName".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("txtPostal".Value)%></div></td>
<td><div align="center"><%=(rsByCity.Fields.Item("txtPhone".Value)%></div></td>
</tr>
<%
Repeat3__index=Repeat3__index+1
Repeat3__numRows=Repeat3__numRows-1
rsByCity.MoveNext()
Wend
%>
<% End If %>
</table>
<%
rsCity.Close()
Set rsCity = Nothing
%>
<%
rsChapter.Close()
Set rsChapter = Nothing
%>
<%
rsUsers.Close()
Set rsUsers = Nothing
%>
<%
rsPostal.Close()
Set rsPostal = Nothing
%>
<%
rsByCity.Close()
Set rsByCity = Nothing
%>
</font id=code></pre id=code>
Replied 04 May 2006 05:30:24
04 May 2006 05:30:24 micah santos replied:
now, i see. you're working on a multiple query string part.
i bookmark the url add u posted here and i will try to create another like yours.
i just hope it won't take me long until you have figured it out by yourself. lol (",)
i bookmark the url add u posted here and i will try to create another like yours.
i just hope it won't take me long until you have figured it out by yourself. lol (",)
Replied 04 May 2006 15:49:41
04 May 2006 15:49:41 Javier Castro replied:
Thanks Micah, <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
I'll do my best not to ruin all the fun....
Cheers,
Javier
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
now, i see. you're working on a multiple query string part.
i bookmark the url add u posted here and i will try to create another like yours.
i just hope it won't take me long until you have figured it out by yourself. lol (",)
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I'll do my best not to ruin all the fun....
Cheers,
Javier
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
now, i see. you're working on a multiple query string part.
i bookmark the url add u posted here and i will try to create another like yours.
i just hope it won't take me long until you have figured it out by yourself. lol (",)
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 05 May 2006 05:38:53
05 May 2006 05:38:53 Javier Castro replied:
Hi Micah,
I have not been able to figure it out. Did you have any luck. I'll keep trying. For now, I'll be using it as is. I know is not as elegant as I would like but it does the job.
Thanks,
Javier
I have not been able to figure it out. Did you have any luck. I'll keep trying. For now, I'll be using it as is. I know is not as elegant as I would like but it does the job.
Thanks,
Javier
Replied 05 May 2006 21:06:56
05 May 2006 21:06:56 micah santos replied:
still working on it... if happened you've figured it out, please let me know too.
tnx.
tnx.