MACROMEDIA COLDFUSION 5-DEVELOPING Manual do Utilizador Página 38

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 47
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 37
ColdFusion MX 7 Getting Started Experience Tutorial Page 38 of 47
The cfif tag in this case translates to “if the current row being processed from the artwork query result set gives a
remainder of 1 after it is divided by 3, print a tr tag to the HTML.”
Using conditional processing with arithmetic operations is a powerful tool for your ColdFusion applications.
19. Add conditional statements around both the opening tr and the ending tr tags, as the following code shows:
<table border="0" cellpadding="15" cellspacing="0" /jointfilesconvert/293559/bgcolor="#FFFFFF">
<cfoutput query="artwork">
<cfif artwork.currentrow mod 3 eq 1>
<tr>
</cfif>
<td valign="top" align="center" width="200">
<img src="images/#artwork.largeImage#" width="200" height="200"><br>
<strong>#artwork.artName#</strong><br>
Artist: #artwork.firstName# #artwork.lastName#<br>
Price: #artwork.price#<br>
#artwork.mediaType# - #artwork.description#<br>
<font color="##FF0000">#artwork.isSold#</font>
</td>
<cfif artwork.currentrow mod 3 eq 0>
</tr>
</cfif>
</cfoutput>
</table>
Learning Point: Rules for using the Number signs
The artwork.currentRow variable does not need to be surrounded by number signs (#) when it is inside a cfif tag.
You can think of the use of number signs as necessary when it’s potentially unclear to ColdFusion what is a variable and
what is not.
Consider these rules:
Number signs are necessary between beginning and ending cfoutput tags, because variables are intermingled with
plain text and HTML tags, and ColdFusion MX 7 needs to be told what to evaluate and what not to evaluate.
Number signs are not necessary inside a cfif tag, because ColdFusion knows to only expect ColdFusion variables
and expressions there.
Number signs are necessary between beginning and ending cfif tags because, like with cfoutput tags, variables
are intermingled with plain text and HTML tags.
Number signs are sometimes necessary in a tag’s attribute values, as in the case of <cfdump var="#artwork#">,
to clarify to ColdFusion that you want the value treated as a variable rather than a literal string.
In the last two bullets, a distinction is made between variables between tags and variables inside a tag’s attributes.
20. Save and browse the page, and then view the page source.
Vista de página 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 46 47

Comentários a estes Manuais

Sem comentários