sqltemplate
tags. So, your file could have two templates in it, and look like this:<?php
include('Sparse.php');
SparseThisPage('username', 'password');
?>
<html>
<!-- some HTML code goes here -->
<sqltemplate ...>
<!-- HTML and Sparse tags go here
-->
</sqltemplate>
<!-- more HTML code goes here -->
<sqltemplate ...>
<!-- More HTML and Sparse tags go here
-->
</sqltemplate>
</html>
sqlrow
.
There must be exactly one of these tags inside every template. The code
inside the row is repeated for every row that's displayed - this can be
the data that's displayed, or new rows to enter for add templates.
Most Sparse tags must either appear inside the sqlrow
(meaning it also would be repeated per row) or outside it (meaning it
would not be repeated) but not both.sqlfield
.
Without this tag you couldn't do anything with the data! sqlfield
tags indicate where you want the data to go - again, either the
existing data, or a place to enter new data (or, when editing data,
both!).sqlaction
.
These tags are replaced by submit buttons depending on where they are
and what kind of template they're in.<?php
include('Sparse.php');
SparseThisPage('username', 'password');
?>
<html>
<h2 align="center">Employee
Database</h2>
<table>
<tr>
<th>Employee
Name</th>
<th>Employee
ID</th>
<th>Employee
Salary</th>
</tr>
<sqltemplate type="edit"
database="myDB" tables="employees">
<sqlrow>
<tr>
<td><sqlfield name="employeeName"
/></td>
<td><sqlfield name="employeeID"
/></td>
<td><sqlfield
name="employeeSalary" /></td>
</tr>
</sqlrow>
</table>
<sqlaction type="edit" />
</sqltemplate>
</span>
h2
, table
,
and table row will be displayed exactly once. sqltemplate
tag,
whose attributes tell us we want to display current data as well
as allowing the user to
edit it. sqlrow
tags,
i.e. the table row defined there, will be repeated for every row of
data we display. sqlfield
tag will display a
widget (probably a text field) populated with the data for that field
in that row.sqlaction
tag, which
appears outside sqlrow
, would turn into a button that reads "Edit
Values", allowing the user to edit all
the values at once. Depending on the type
attribute of that tag and the template type, sqlaction
can also add new
information, delete rows, or navigate forward or backwards in the data.
Previous: Introduction | Templates - Overview | Next: Templates and Queries