以下のコードは機能しますが、その値のレコードがない場合は「レコードがありません」というメッセージを表示したいと思い
<cfif GetResults2.csedept_id eq aFieldValue>
ます。カウンターを付けようとしましたが、「レコードがありません」と表示されず、
<thead> <th>Name</th> <th>Positive Comment</th> <th>Negative Comment</th></thead>
レコードがない場合はテーブルの見出しも表示されません。
結果が空に戻った場合、「No Records」を表示してテーブル ヘッドを非表示にするにはどうすればよいですか
現在、結果が空に戻った場合、「結果がありません」(正しい) と表示され、ヘッダーが表示されます (正しくない)。
<cfset counter3= 0>
<table cellpadding="0" cellspacing="0" class="tablecolors">
<h2> Comments </h2>
<thead> <th>Name</th> <th>Positive Comment</th> <th>Negative Comment</th></thead>
<cfloop query="GetResults2">
<cfif GetResults2.csedept_id eq aFieldValue>
<tr>
<td nowrap="nowrap">#emp_namefirst# #Left(emp_namelast, 1)# </td>
<td>#Replace(commentpositive, emp_namefirst, "<B>" & emp_namefirst & "</B>")#</td>
<td>#Replace(commentnegative, emp_namefirst, "<B>" & emp_namefirst & "</B>")#</td>
</tr>
<cfelse><p>no records</p>
</cfif>
</cfloop>
</table>
更新:追加するために、@ FRANKが言ったように、上記の別のクエリがあり、たとえば、ほぼ同じことを行います:
'<cfloop query="GetEmployeeTotals3">
<cfif GetEmployeeTotals3.csedept_id eq aFieldValue> '
クエリは次のとおりです。
select GetResults.* , GetEmployees.emp_namefirst, GetEmployees.emp_namelast
from GetResults, GetEmployees
where employee = emp_id
order by csedept_id
そのため、私が試した上記のすべてのソリューションは機能しません。