我有以下字符串,我想拆分该字符串以表格格式显示数据,但我想显示的方式不起作用,这是数据,这里是它应该是什么样子
vendorname- #name#: city-#city#: state-#state#:zip-#zip#:in network-#innetwork#
我想创建上面的表格如下:
<table>
<tr>
<td>vendorname</td><td>#vendorname#</td>
<td>city</td><td>#city#</td>
<td>state</td><td>#state#</td>
</tr>
<tr><td>zip</td><td>#zip#</td>
<td> </td><td> </td>
<td> </td><td> </td>
</tr>
</table>
尝试在一个TR中创建6列
到目前为止这是尝试
<table align="center" width="100%" border="0" cellpadding="4" cellspacing="6" bordercolor="#CCCCCC;">
<tr>
<cfloop index="aPair" list="#Demo_Details#" delimiters=":">
<cfset Key= listFirst(aPair,"-")>
<cfif listLen(apair,"-") gt 1>
<cfset value= listLast(aPair,"-")>
<cfelse>
<cfset value = "">
</cfif>
<cfoutput>
<td><strong>#key#</strong></td>
<td>#value#</td>
</cfoutput>
</cfloop>
</tr>
</table>
它没有按预期生成列,它以单行显示所有内容
答案 0 :(得分:0)
这样的事情
<cfset Vendor = "">
<cfset City = "">
<cfset State = "">
<cfset ZIP = "">
<cfloop index="aPair" list="#Demo_Details#" delimiters=":">
<cfset Key= listFirst(aPair,"-")>
<cfif listLen(apair,"-") gt 1>
<cfset SetVariable(key, listLast(aPair,"-")>
</cfif>
</cfloop>
<cfoutput>
<table align="center" width="100%" border="0" cellpadding="4" cellspacing="6" bordercolor="#CCCCCC;">
<tr>
<td>vendorname</td><td>#vendorname#</td>
<td>city</td><td>#city#</td>
<td>state</td><td>#state#</td>
</tr>
<tr>
<td>zip</td><td>#zip#</td>
<td> </td><td> </td>
<td> </td><td> </td>
</tr>
</table>
</cfoutput>