|
A macro to display the contents of an SQL query as an HTML table |
|
Contents of macro.lib
GENERIC_TABLE(query)
$if(true)
$do(rset=conn.query($query))
<table bgcolor="#666666" cellpadding=1 cellspacing=0><tr><td>
<table cellpadding=1 cellspacing=1 border=0>
<tr bgcolor="#999999">
$declare(int cols=rset.getColumns())
$declare(int i)
$for(i=0;i<cols;i++)
<td><font color="#FFFFFF"><b>$(rset.getColumnName(i))</b></font></td>
$endfor
</tr>
$while(rset.next())
<tr bgcolor="#FFFFFF">
$for(i=0;i<cols;i++)
<td>$(rset.getString(i))</td>
$endfor
</tr>
$endwhile
</table>
</td></tr></table>
$endif <br>
| |
Example page that uses macro.lib
$use("codex.sql")
$use("codex.util")
$use("codex.http")
#readdefs("macro.lib")
<html>
<body>
$declare(MySQLConnection conn = new MySQLConnection("localhost","test","root",""))
$declare(String query)
$declare(MySQLResultSet rset)
$GENERIC_TABLE("SELECT * FROM tblTopic")
</body>
</html>
| |
|
Copyright © 2000 - 2003 David Hakim