## ## Document History ## ## Created (peeje01) ## 27-Apr-1999 (peeje01) ## Change include file name from -h.html to _h.html ## 02-Apr-2004 (fanra01) ## Bug 112091 ## Editorial changes from griel02. ## Graphical Hyperlinks

Graphical Hyperlinks

Our first attempt at building a hyperlink list of play types was simple and effective but we would much rather use a graphical link to do this. In the second of this series of examples we build a link by embedding the HTML tags directly in the select statement.
We set the return address as before.

File: play_typeGLink.html

<html>
<head>
<title>Graphical Hyper Link to Shakespeare's Plays by type</title>
</head>
<body>
<h1>Graphical Hyper Link to Shakespeare's Plays by type</h1>

<!-- #ICE REPEAT INCLUDE=`plays[play_TxnCndCmt_h.html]` -->

<!-- #ICE REPEAT
          DATABASE = `icetutor` 
          SQL=`select distinct
              '<a href="/ice-bin/oiice.dll/playgroup/plays[play_typeLinkSubSet.html]?type=', type, '">
	      <img src="/ice-bin/oiice.dll/playgroup/plays[', type, '.gif]" alt="', type, '">
	      </a>'
		from plays`
          TRANSACTION=`t_type` 
          CURSOR=`c_type` 
          ROWS=`-1` 
          TYPE=`PLAIN`
          -->
<!-- #ICE COMMIT=`t_type` -->
<!-- #ICE DECLARE=`session.e_return=play_typeGLink.html` -->

<!-- #ICE REPEAT INCLUDE=`plays[play_SessionControl_h.html]` -->
</body>
</html>

The first thing we notice is that the select statement has become far more complicated than it was. We are making use of the ability to embed static text within the statement to embed the tags for a hyperlink. We select the type column three times in all. First, to pass in as the value of the variable passed to the target document; second as the name of the image file (we hard code the extension); and finally, as the alternative text to the image as follows:

SQL=`select distinct
'<a href="/ice-bin/oiice.dll/playgroup/plays[play_typeLinkSubSet.html]?type=', type, '">
    <img src="/ice-bin/oiice.dll/playgroup/plays[', type, '.gif]" alt="', type, '">
    </a>'
    from plays`

The first line introduces the select. The second line sets up the hyperlink anchor tag with the variable type and passes the contents of the type column as the value. The third line again uses the contents of the type column in two places, the first as the name of the image file (with the hard coded extension) and the second as the alternate text for the image.

Both the link and the value of the HTML variable type are built dynamically in this document. We note that, although in this case the image files are constrained to have the same names as the various play types, this is

We set the value of the session variable e_return so as to re-use the display document from before.

This document achieved the aim of dynamically creating a set of graphical hyper links but at the expense of placing HTML code within the select statement. We would prefer to abstract the HTML away from the SQL and this is made possible by the HTML and SWITCH keywords.