Database Reference
In-Depth Information
list << cgi . dt { CGI . escapeHTML ( row [ "note" ]. to_s ) }
list << cgi . dd { CGI . escapeHTML ( row [ "mnemonic" ]. to_s ) }
end
end
list = cgi . dl { list }
Here is another example (in Perl). Each term is a database name, and the corresponding
definition indicates how many tables are in the database. The numbers are obtained
from INFORMATION_SCHEMA using a query that counts the number of tables in each da‐
tabase. Create the terms and definitions by invoking dt() and dd() , save them in an
array, and pass the array to dl() :
# count number of tables per database
my $sth = $dbh -> prepare ( "SELECT TABLE_SCHEMA, COUNT(TABLE_NAME)
FROM INFORMATION_SCHEMA.TABLES
GROUP BY TABLE_SCHEMA" );
$sth -> execute ();
my @items ;
while ( my ( $db_name , $tbl_count ) = $sth -> fetchrow_array ())
{
push ( @items , dt ( escapeHTML ( $db_name )));
push ( @items , dd ( escapeHTML ( $tbl_count . " tables" )));
}
print dl ( @items );
The counts indicate the number of tables accessible to the MySQL user account that the
script uses when it connects to the MySQL server. Databases or tables not accessible to
that account are not included.
Nested lists
Some information is most easily understood when presented as a list of lists. The fol‐
lowing example displays state names as a definition list, grouped by initial letter of the
names. For each item in the list, the term is the initial letter, and the definition is an
unordered list of the state names beginning with that letter:
A
• Alabama
• Alaska
• Arizona
• Arkansas
C
• California
• Colorado
• Connecticut
D
• Delaware
Search WWH ::




Custom Search