MACROMEDIA COLDFUSION 5-DEVELOPING Instrukcja Użytkownika Strona 40

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 47
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 39
ColdFusion MX 7 Getting Started Experience Tutorial Page 40 of 47
Learning Point: Boolean values and cfif
Boolean variables store true (1) or false (0) values. Conditional statements must evaluate to true or false. Therefore, if a
variables stores a value of 1, ColdFusion will also interpret it as a true statement.
<font color="##FF0000">
<cfif artwork.isSold>
Sold!
</cfif>
</font>
Figure 57. Displaying the
word Sold! in the browser
The word Sold! only appears where needed.
Now imagine you created this page as static HTML; when you show it to your client, she says, “Very nice, but could
you please alphabetize the display by the art piece name?” This would take you a long time to modify in static HTML,
even using the easy Dreamweaver interface. With ColdFusion, this is a small change to the query.
23. Modify the SQL statement in the cfquery tag to include an ORDER BY clause, which tells the database to
alphabetize the results by the column specified, as the following code shows:
<cfquery name="artwork" datasource="cftutorial">
SELECT FIRSTNAME, LASTNAME, ARTNAME, DESCRIPTION, PRICE, LARGEIMAGE, ISSOLD, MEDIATYPE
FROM ARTISTS, ART, MEDIA
WHERE ARTISTS.ARTISTID = ART.ARTISTID
AND ART.MEDIAID = MEDIA.MEDIAID
ORDER BY ARTNAME
</cfquery>
24. Save and browse your page.
Przeglądanie stron 39
1 2 ... 35 36 37 38 39 40 41 42 43 44 45 46 47

Komentarze do niniejszej Instrukcji

Brak uwag