How to Add Queries to your page

Add queries to your pages using the following syntax:

{* foreach rec in “DSN:query” *}
{* rec.field1 *} {* rec.field2 *} {* rec.field3 *}
{* next *}

You can put any HTML you want around it, so if you wanted the result to look like a table, you would do this (assume a DSN called ContactsDB, with a table named Contacts):

<table border=1>
<tr>
<td>Name</td><td>Phone Number</td>
</tr>
{* foreach rec in
“ContactsDB:select * from Contacts” *}
<tr>
<td>{*rec.name*}</td><td>{*rec.phone*}</td>
</tr>
{* next *}
</table>

After being run it would look like this:

Name Phone Number
Mike Smith (212) 555-1212
Jenny Jones (212) 555-3344
John Doe (212) 555-1234

The loops are not nestable.

The query is any legal select statement on the database being queried. For instance select * from tablename. If you need a double quote in the query, use two double quotes.

Inside the foreach and next, you can put field accessors with the format:

{* var_from_foreach.fieldname *}

where var_from_foreach is the variable used in the enclosing foreach statement and the fieldname is any field from the query result.