Forums

ASP

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

%>
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> &lt;%
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
%&gt;
&lt;%
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
%&gt;
&lt;%
Dim rsUsers__MMColParam
rsUsers__MMColParam = "0"
If (Request.QueryString("search" &lt;&gt; "" Then
rsUsers__MMColParam = Request.QueryString("search"
End If
%&gt;
&lt;%
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
%&gt;
&lt;%
Dim rsPostal__MMColParam
rsPostal__MMColParam = "0"
If (Request.QueryString("spostal" &lt;&gt; "" Then
rsPostal__MMColParam = Request.QueryString("spostal"
End If
%&gt;
&lt;%
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
%&gt;
&lt;%
Dim rsByCity__MMColParam
rsByCity__MMColParam = "0"
If (Request.QueryString("bycity" &lt;&gt; "" Then
rsByCity__MMColParam = Request.QueryString("bycity"
End If
%&gt;
&lt;%
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
%&gt;
&lt;%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsUsers_numRows = rsUsers_numRows + Repeat1__numRows
%&gt;
&lt;%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
rsPostal_numRows = rsPostal_numRows + Repeat2__numRows
%&gt;
&lt;%
Dim Repeat3__numRows
Dim Repeat3__index

Repeat3__numRows = -1
Repeat3__index = 0
rsByCity_numRows = rsByCity_numRows + Repeat3__numRows
%&gt;


&lt;div align="left"&gt;
&lt;p class="pageheader"&gt;Search Contractor&lt;/p&gt;


&lt;table border="0" align="center" cellpadding="1" cellspacing="1"&gt;
&lt;tr valign="top"&gt;
&lt;td&gt;&lt;form name="form3" method="get" action="asearch.asp"&gt;
&lt;label&gt; By City
&lt;select name="bycity" id="bycity"&gt;
&lt;option value="value"&gt;Select a City&lt;/option&gt;
&lt;%
While (NOT rsCity.EOF)
%&gt;
&lt;option value="&lt;%=(rsCity.Fields.Item("cityID".Value)%&gt;"&gt;&lt;%=(rsCity.Fields.Item("cityName".Value)%&gt;&lt;/option&gt;
&lt;%
rsCity.MoveNext()
Wend
If (rsCity.CursorType &gt; 0) Then
rsCity.MoveFirst
Else
rsCity.Requery
End If
%&gt;
&lt;/select&gt;
&lt;input type="submit" value="Search"&gt;
&lt;/label&gt;
&lt;/form&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="top"&gt;
&lt;td&gt;&lt;form name="form1" method="get" action="asearch.asp"&gt;
&lt;label&gt; Region
&lt;select name="search" id="select2"&gt;
&lt;option value="value"&gt;Select a Region&lt;/option&gt;
&lt;%
While (NOT rsChapter.EOF)
%&gt;
&lt;option value="&lt;%=(rsChapter.Fields.Item("ChapterID".Value)%&gt;"&gt;&lt;%=(rsChapter.Fields.Item("ChapterName".Value)%&gt;&lt;/option&gt;
&lt;%
rsChapter.MoveNext()
Wend
If (rsChapter.CursorType &gt; 0) Then
rsChapter.MoveFirst
Else
rsChapter.Requery
End If
%&gt;
&lt;/select&gt;
&lt;/label&gt;
&lt;label&gt;
&lt;input type="submit" value="Search"&gt;
&lt;/label&gt;
&lt;/form&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="top"&gt;
&lt;td&gt;&lt;form name="form2" method="get" action="asearch.asp"&gt;
&lt;label&gt;Postal
&lt;input name="spostal" type="text" id="spostal" size="7" maxlength="7"&gt;
&lt;/label&gt;
&lt;label&gt;
&lt;input type="submit" value="Search"&gt;
&lt;/label&gt;
&lt;/form&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;span class="newstitle"&gt;Results&lt;/span&gt;
&lt;table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#DE2D3B"&gt;
&lt;tr class="menu"&gt;
&lt;td&gt;Company&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;City&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;Region&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;Postal&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;Phone&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;% If (rsUsers_total) = 0 Then %&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsUsers.EOF))
%&gt;
&lt;tr bgcolor="#FFFFFF"&gt;
&lt;td&gt;&lt;%=(rsUsers.Fields.Item("txtCompanyName".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsUsers.Fields.Item("cityName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsUsers.Fields.Item("ChapterName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsUsers.Fields.Item("txtPostal".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsUsers.Fields.Item("txtPhone".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsUsers.MoveNext()
Wend
%&gt;
&lt;% End If %&gt;

&lt;!-- postal code --&gt;

&lt;% If (rsPostal_total) = 0 Then %&gt;

&lt;%
While ((Repeat2__numRows &lt;&gt; 0) AND (NOT rsPostal.EOF))
%&gt;
&lt;tr bgcolor="#FFFFFF"&gt;

&lt;td&gt;&lt;%=(rsPostal.Fields.Item("txtCompanyName".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsPostal.Fields.Item("cityName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsPostal.Fields.Item("ChapterName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsPostal.Fields.Item("txtPostal".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsPostal.Fields.Item("txtPhone".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat2__index=Repeat2__index+1
Repeat2__numRows=Repeat2__numRows-1
rsPostal.MoveNext()
Wend
%&gt;
&lt;% End If %&gt;
&lt;!-- end postal code --&gt;
&lt;% If (rsByCity_total) = 0 Then %&gt;

&lt;%
While ((Repeat3__numRows &lt;&gt; 0) AND (NOT rsByCity.EOF))
%&gt;
&lt;tr bgcolor="#FFFFFF"&gt;

&lt;td&gt;&lt;%=(rsByCity.Fields.Item("txtCompanyName".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsByCity.Fields.Item("cityName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsByCity.Fields.Item("ChapterName".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsByCity.Fields.Item("txtPostal".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;%=(rsByCity.Fields.Item("txtPhone".Value)%&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat3__index=Repeat3__index+1
Repeat3__numRows=Repeat3__numRows-1
rsByCity.MoveNext()
Wend
%&gt;

&lt;% End If %&gt;
&lt;/table&gt;


&lt;%
rsCity.Close()
Set rsCity = Nothing
%&gt;
&lt;%
rsChapter.Close()
Set rsChapter = Nothing
%&gt;
&lt;%
rsUsers.Close()
Set rsUsers = Nothing
%&gt;
&lt;%
rsPostal.Close()
Set rsPostal = Nothing
%&gt;
&lt;%
rsByCity.Close()
Set rsByCity = Nothing
%&gt;


</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 (",)
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>
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
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.

Reply to this topic