0
我有兩個查詢,每個查詢輸出在單獨的表中的屏幕上。兩個quires都有相同數量的記錄,但我想檢查每個字段是否相等,如果不是,我想爲該表格行設置不同的背景顏色。這裏是我到目前爲止的代碼:比較兩個錶行值ColdFusion?
<cfquery name="oldData" datasource="test">
SELECT
old_id,
old_userid,
old_first,
old_last,
old_dob
FROM OldTest
</cfquery>
<cfquery name="newData" datasource="test">
SELECT
new_id,
new_userid,
new_first,
new_last,
new_dob
FROM NewTest
</cfquery>
這裏是兩個表代碼:
<table>
<tr>
<td valign="top">
<table class="oldData">
<caption>Old Data</caption>
<thead>
<tr>
<th>ID</th>
<th>UserID</th>
<th>First</th>
<th>Last</th>
<th>DOB</th>
<tr>
</thead>
<tbody>
<cfoutput query="oldData">
<tr>
<td>#old_id#</td>
<td>#Trim(old_userid)#</td>
<td>#Trim(old_first)#</td>
<td>#Trim(old_last)#</td>
<td>#Trim(old_dob)#</td>
</tr>
</cfoutput>
</tbody>
</table>
</td>
<td valign="top">
<table class="newData">
<caption>New Data</caption>
<thead>
<tr>
<th>ID</th>
<th>UserID</th>
<th>First</th>
<th>Last</th>
<th>DOB</th>
<tr>
</thead>
<tbody>
<cfoutput query="newData">
<tr>
<td>#new_id#</td>
<td>#Trim(new_userid)#</td>
<td>#Trim(new_first)#</td>
<td>#Trim(new_last)#</td>
<td>#Trim(new_dob)#</td>
</tr>
</cfoutput>
</tbody>
</table>
</td>
</tr>
</table>
我不知道我是否應該輸出像之前比較數據行:
<cfif oldData.old_first[currentrow] NEQ newData.new_first[currentrow]>
<cfset rowColor = "red">
</cfif>
或者有更好的方法來解決這個問題。如果有人知道更好的方式,請讓我知道。
我不確定我是否理解你的例子中的同情心是如何運作的。你能解釋一下嗎? –
您是指Q的Q還是'
tr標籤在上面的答案中。 –
我會用循環:
如果你希望你可以環繞紅素和TDS循環。
該方法還消除了對資源密集型QofQ的需求。
來源
2017-01-19 15:27:07 Jules
相關問題