how to add a brief message when a page is blank

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karen987
    New Member
    • Mar 2007
    • 114

    how to add a brief message when a page is blank

    the page below is called "todays newslog" and it automatically draws out news articles posted within a 24 hour period. It is an asp page updated each midnight.

    During the time Midnight to whenver the first article is added, the page is blank. I would like to add this statement to the blank page only, so that it doesn't show after the first article is added. ie. it should only until news is added.

    "No news added yet. please check later"

    I would appreciate some suggestions, as to what code to add and where. Here is the code of the page below

    Thanks in advance.


    Code:
    <!--#include file="inc_header.asp"--> 
    
    
    <% Dim SetDate, EndDate, QueryDate, CATEGORIES, POP_DROP
    
    	QueryDate = Request.QueryString("D")
    	
    	If IsDate(QueryDate) THEN	
    		QueryDate = CDate(QueryDate)	
    	ELSe
    		QueryDate = Date()
    	END IF
    		
    	SetDate = QueryDate
    	EndDate = QueryDate + 1	
    	
    	
    	Call OPEN_DB()		
    	
    	SQL = "SELECT fldCREATED FROM nm_tbl_news GROUP BY fldCREATED ORDER BY fldCREATED DESC"
    	Set RS = Server.CreateObject("ADODB.Recordset")
    	RS.LockType   = 1 
    	RS.CursorType = 0 
    	RS.Open SQL, MyConn	
    		 WHILE NOT RS.EOF 
    		 	blSEL = ""
    		 	If NOT Instr(POP_DROP, FormatDateTime(RS("fldCREATED"),2)) > 0 THEN
    				'IF Trim(QueryDate) = Trim(FormatDateTime(RS("fldCREATED"),2)) THEN blSEL = " selected"
    		 		POP_DROP = POP_DROP & "<option " & blSEL & " value='TodaysWeblog.asp?D=" & FormatDateTime(RS("fldCREATED"),2) & "'>" & FormatDateTime(RS("fldCREATED"),2) & vbcrlf
    			END IF
    		    RS.MoveNext
    		 WEND
    	RS.Close 
    	Set RS = Nothing
            Dim DATE_F
            DATE_F = GET_SETTINGS(False, "fldDATE_F")
    
    %>
    
    <script language="JavaScript" type="text/javascript">
        function Jump(fe){
            var opt_key = fe.selectedIndex;
            var uri_val = fe.options[opt_key].value;
            window.open(uri_val,'_top');
            return true;
        }
    </script>
    
    
    <table width="752" align="center" cellpadding="2" cellspacing="0" border="0">
      <tr>	<td width="628" align="left" valign="top"><table width="592">
          <tr>
            <th width="237" align="left" scope="col"><img src="../pix/tout/todaysweblog.JPG" alt="todays news" width="150" height="21" align="top"></th>
            <th width="379" align="left" valign="bottom" scope="col"><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif">&nbsp;&nbsp;<span style="font-size: 9px; font-style: italic">updated every midnight </span> </span></span><strong style="font-size: 12px;"><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif"><strong style="font-size: 12px;">&nbsp;&nbsp;&nbsp; <%=QueryDate%></strong></span>&nbsp;</strong><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: #808080">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong style="font-size: 12px;"> <br />
            </strong></th>
          </tr>
        </table>
    
    	  <table width="595" height="199" align="left" cellpadding="2" cellspacing="2">
            <% Dim I 
    		
    		I = 1
    		SQL = "SELECT nm_tbl_news.ID AS NID, nm_tbl_news.fldSUMMARY AS SUMMARY, nm_tbl_news.fldIMAGE AS NIMAGE, nm_tbl_news.fldTITLE AS TITLE, nm_tbl_agent.fldNAME AS ANAME, nm_tbl_news.fldPOSTED AS POSTED, fldCREATED FROM nm_tbl_news, nm_tbl_agent WHERE (nm_tbl_agent.ID = nm_tbl_news.fldAID) AND (nm_tbl_news.fldACTIVE=1) AND (fldCREATED > #" & SetDate & "# AND fldPOSTED < #" & EndDate & "# ) AND (Now() BETWEEN fldCREATED AND fldEXPIRES) ORDER BY nm_tbl_news.fldPOSTED DESC"		
    		
    		Set RS = Server.CreateObject("ADODB.Recordset")
    		RS.LockType   = 1
    		RS.CursorType = 0
    		RS.Open SQL, MyConn	
    			 WHILE NOT RS.EOF 			 	
    				NID     = trim(RS("NID"))
    	            SUMMARY = trim(RS("SUMMARY"))
    	            IMAGE   = trim(RS("NIMAGE"))
    	            TITLE   = trim(RS("TITLE"))
    	            AUTHOR  = trim(RS("ANAME"))
    	            POSTED  = trim(RS("POSTED"))	
    				CREATED  = trim(RS("fldCREATED"))
    				CATEGORIES = GET_CATES(NID)				
    				%>
            <%'IF Trim(FormatDateTime(POSTED,2)) = Trim(SetDate) THEN%>
            <%IF I = 1 THEN%>
            <tr>
              <td width="585" height="98" align="left" valign="top" style="padding: 5px;"><a href="../news.asp?ID=<%=NID%>" class="NavigLNK"><%=TITLE%></a><br /> 
                 
                    <span class="divPOSTEDON">Category: <%=CATEGORIES%></span><%END IF%> <br />
    
                 <%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
                  <img src="<%=IMAGE%>" width="70" height="80" vspace="5" border="0" align="left" />
                  <% END IF %> <%= FormatDateTime(POSTED,DATE_F) %> <%IF SHOW_AUTHOR = True THEN%> 
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [By: <%=AUTHOR%>]<br />
                  <span class="tdSUMMARY"><%= SUMMARY %> <br />
                  </span><br /><hr width="100%" size="1" style="color: gray ;height: 1px;" />
              </td>
            </tr>
            <%ELSE%>
            <tr>
              <td width="585" align="left" valign="top" style="padding: 5px;; font-size: 12px"><div align="justify">
                  <%IF NOT (IMAGE = "" OR IsNull(IMAGE)) THEN%>
                  <img src="<%=IMAGE%>" width="50" height="50" border="1" />
                  <%ELSE%>
                &nbsp;
                <%END IF%>
              </div></td>
            </tr>
            <%END IF%>
            <%'END IF%>
            <%
    				I = I + 1
    				IF I > 1 THEN I = 1				
    			    RS.MoveNext
    			 WEND
    		RS.Close 
    		Set RS = Nothing
    		
    		MyConn.Close
    		Set MyConn = Nothing		
    		
    		
    		%>
  • stepterr
    New Member
    • Nov 2007
    • 157

    #2
    You could probably use

    Code:
    If rs.RecordCount = 0 Then 'no records found
          ...do something...
    End If
    before you go into your while statement.

    Comment

    Working...