Nothing displays if No Record is found

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Nothing displays if No Record is found

    <CFQUERY NAME="EMP_DATA" DATASOURCE="EMP">
    select a.*, b.locname, c.ou
    from emptbl a, loctbl b, outbl c
    where a.ouid = c.ouid and a.locid = b.locid
    <cfif #Birthday# is "Yes">and a.DOB = '#DateFormat(Now(),"mmmm dd")#'</cfif>
    <cfif #Anniversaries# is "Yes"><cfset today = #dateformat(now(),"mm/dd")#>
    and Left(hiredate, 5) = '#Left(today, 5)#'</cfif>
    <cfif #Search_Lname# is "Yes">and a.lname Like
    '%#Search_LName_input#%'</cfif>
    <cfif #Search_Fname# is "Yes">and a.fname Like
    '%#Search_FName_input#%'</cfif>
    <cfif #Search_EXT# is "Yes">and a.EXT Like '%#Search_EXT_input#%'</cfif>
    <cfif #Search_locname# is "Yes">and a.locname Like
    '%#Search_locname_input#%'</cfif>
    ORDER BY
    <cfif #Sort# is "Last_Asc">a.LNAME
    <cfelseif #Sort# is "Last_DESC">a.LNAME DESC
    <cfelseif #Sort# is "First_ASC">a.FNAME
    <cfelseif #Sort# is "First_DESC">a.FNAME DESC
    <cfelseif #Sort# is "EXT_ASC">a.EXT
    <cfelseif #Sort# is "EXT_DESC">a.EXT DESC
    <cfelseif #Sort# is "locname_ASC">a.locname
    <cfelseif #Sort# is "locname_DESC">a.locname DESC<cfelse>a.LNAME</cfif>
    </CFQUERY>

    <body leftmargin="0" topmargin="0" alink="#000000" link="#000000"
    vlink="#000000">
    <table width="100%" height="25" border="1" cellpadding="0" cellspacing="0">
    <cfoutput query="EMP_DATA">
    <cfif emp_data.recordcount gt 0>

    <tr bgcolor="###iif(currentrow MOD 2,DE('EEE8AA'),DE('ffffff'))#"
    height="25">
    <td width="110" nowrap>&nbsp;&nbsp;<a
    href="EMP_Data.cfm?login=yes&EMPID=#ID#"
    target="rightFrame"><b>#lname#</b></a></td>
    <td width="110" nowrap>&nbsp;&nbsp;#fname#</td>
    <td width="65" nowrap>&nbsp;&nbsp;#ext#</td>
    <td nowrap width="200">&nbsp;&nbsp;#ou# </td>
    <td nowrap>&nbsp;&nbsp; #locname#&nbsp;&nbsp;</td>
    </tr>
    <cfelse>
    <tr bgcolor="###iif(currentrow MOD 2,DE('EEE8AA'),DE('ffffff'))#"
    height="25">
    <td width="110" nowrap>&nbsp;&nbsp;</td>
    <td width="110" nowrap>&nbsp;&nbsp;</td>
    <td width="65" nowrap>&nbsp;&nbsp;</td>
    <td nowrap width="200">&nbsp;&nbsp;</td>
    <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
    </tr>
    </cfif>
    </cfoutput>

    </table>

    I've tried testing for emp_data.recordcount eq 0 then display but still
    nothing will display. Not even a blank table with blank rows. Nothing.

    RuBot Guest

  2. Similar Questions and Discussions

    1. How can i retrieve record ONLY From 300 - 400 in amillion Record Table?
      HI all Thanks for your time.. I have a question here.. How can i retrieve record ONLY From XXX - XXX in a million Record Table? eg. I have a...
    2. ASP newby needs no record found help
      ok I'm new to ASP but I have everything working great I have a form in which client can look up status i want to be able to redirect to a no record...
    3. Find record w/ conditions met in the same child record
      I'll use 2 files to demonstrate my question. The first file is Animal. It has 4 fields. Id (serial number) ZooId (number) Name (text) Food...
    4. using dropdown box to display db record & update record
      Hi Folks, I have a web database written in asp and using access97. I have many projects, but each project is being held responsible by a person....
    5. Stop adding record in subform after record count = 1
      Can someone help in in what to put after the THEN statment to allow one entry if the Record count is =>1 in the Before insert or should I set the...
  3. #2

    Default Re: Nothing displays if No Record is found

    Also, it was orignally

    <cfif emp_data.recordcount eq 0>
    <tr><td colspan="5">No record Found.</td></tr>
    RuBot Guest

  4. #3

    Default Re: Nothing displays if No Record is found

    Hi

    You need to put the CFIF statement outside the <cfoutput query="EMP_DATA">. If
    the query has no results then the <cfoutput query="EMP_DATA"> will not be
    looping at all. There are no records so the <cfoutput query="EMP_DATA"> will be
    skipped totally.

    so you want something like this:

    <CFIF emp_data.recordCount GT 0>
    <cfoutput query="EMP_DATA">
    table output code
    </cfoutput>
    <CFELSE>
    no records message/table output
    </CFIF>

    Zoe

    zoeski80 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139