docs.roxen.comView this page in a printer friendly mode
DocsRoxen2.1TutorialsDatabase Tutorial
Copyright  2001, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com



Installing MySQL
Privileges
Building a Sample Database
The query() function
The big_query() function
Quoting
SQL Syntax
Conditions
Sorting
Limiting
Functions
Features Missing from MySQL
Insertion Syntax
The tablify Container
The Business Graphics Module
The emit and sqlquery Tags
Database Creation
Creating Tables
Indices
Dropping

The tablify Container

This page isn't meant to be a reference for tablify, as it can be found on the <tablify> page.

The <tablify> container can be used to make (plain or nice) HTML tables out of formatted text, as well as allowing to perform some operations on the data like sorting.

Of course it is not mandatory to use it to build tables, but it can save some work, especially to build "nice" tables. The <sqltable> tag can be used for the same purpose too, but it doesn't have the same flexibility, and it is being slowly phased out, so support for it might be dropped in the future.

Build a table with <emit> to print the total area of each known nation:


<table border="1">
<tr><th>Country</th><th>Total area</th></tr>
<emit source="sql"
      host="mysql://user:password@localhost/sample"
     query="SELECT name,area_tot FROM ids,countries
             WHERE ids.code=countries.country">
<tr><td><ent>_.name</ent></td>
    <td><ent>_.area_tot</ent></td></tr>
</emit>
</table> 

Doing the same with tablify:


<tablify nice="yes" interactive-sort="yes" size="3"
         titlecolor="white" cellseparator="|">
Country|Total Area
<emit source="sql"
      host="mysql://user:password@localhost/sample"
     query="SELECT name,area_tot FROM ids,countries
             WHERE ids.code=countries.country">
<ent>_.name</ent>|<ent>_.area_tot</ent>
</emit>
</tablify> 

Tablify expects to receive its data in a tabular form, with newline-separated rows of tab-delimited entries. In this case I chose to override the default cell separator because some editors try to translate the tab character to a sequence of spaces. Should you choose to do the same, make sure that your delimiter is a character that does not occur in your dataset.

While I shamelessly used the interactive-sort parameter to tablify, it is not recommendable to use the tablify sorting functions in general, but rather using the SQL "order by" clause for performance reasons.