Chapter 5. HTMLGENTABLE - Generating an html table dynamically with row effect

Type: standalone function

Location: nosod.lib

htmlgentable(arg1, arg2, arg3, arg4, arg5)


Output: string (returned)

This function has for goal to generate automatically an html table content, as HTMLGEN, but is dedicated to produce table effects with one row on two having a different backgroud color. The provide higher visibility in the table produced in the html output.

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++).

In arg3, you must give the name of the background color variable defined in the row template as well. E.g. for a ++vbgcolor++ in the template, provide "bgcolor" in arg3.

In arg4 and arg 5, provide hexadecimal colors for rows background. E.g. #CCCCCC and #AAAAAA

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.

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))  

 eval(htmlgentable("IN0K_INFO","<tr bgcolor=\"++vbgcolor++\">
    <td><font face=\"Courier New\">++v1++</font></td>
    <td><font face=\"Courier New\">++v2++</font></td>