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

   

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>&_.name;</td>
    <td>&_.area_tot;</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">
&_.name;|&_.area_tot;</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.