Chapter 4. HTMLGEN - Generating an html table dynamically

Type: standalone function

Location: nosod.lib

htmlgen(arg1, arg2)


Output: string (returned)

This function has for goal to generate automatically an html table content. The approach is to provide in 'arg1' the name of the array prepared by a previous process. This array must be two dimensions, where the first dimension is the row (starting at 0), and the second dimension is the column (starting at 0).

In arg2, you put as string a subpart of html table, identifying the row template. Inside the row template, put the characters '++vx++' at each place of a data, where x is the column number + 1 (means you start with ++v1++).

The function will return the complete html table generated. It's usefull when you generate a table from a database query, and that you do not know in advance how must row the table will contain. This function can be used also for generating html dropdowns and lists, as the template principle is the same.

Example: Suppose your html template file contain something like


The source code generating the html output will be something like:

 while ($r = $IN0DB->queryFetch($query))  

    <td><font face=\"Courier New\">++v1++</font></td>
    <td><font face=\"Courier New\">++v2++</font></td>