create table employees(id integer(11) not null, name
varchar(255), gender enum('m','f'), salary real, notes text, primary
key(id));
<?php
include('Sparse.php');
SparseThisPage('myUsername',
'myPassword');
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
<enumset
id="gender">
<enum
key="m" value="Male" />
<enum
key="f" value="Female" />
</enumset>
<sqltemplate
database="myDB" tables="employees"
limit="5" type="edit" constraints="ORDER BY name">
<table
border='1'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Gender</th>
<th>Salary</th>
<th>Notes</th>
<th>Action</th>
</tr>
<sqlrow>
<tr>
<td><sqlfield
name="ID"
type="text"/></td>
<td><sqlfield
name="name"/></td>
<td><sqlfield
name="gender"
enumset="gender"/></td>
<td>$<sqlfield
name="salary"
/></td>
<td><sqlfield
name="notes"
/></td>
<td><sqlaction
type="edit" /><sqlaction
type="delete" /></td>
</tr>
</sqlrow>
<tr><td
colspan="6" align="center"><sqlaction
type="previous" /><sqlaction
type="next" /></td></tr>
</table>
</sqltemplate>
</body>
</html>
ID | Name | Gender | Salary | Notes | Action |
---|---|---|---|---|---|
15 | $ | ||||
12 | $ | ||||
31 | $ | ||||
23 | $ | ||||
7 | $ | ||||
However, if you're willing to forego the nice Male/Female select box and the non-editablity of the ID field, you can do the entire thing in one tag:
<?php
include('Sparse.php');
SparseThisPage('myUsername',
'myPassword');
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<body>
<sqlquick
database="myDB" tables="employees"
limit="5" type="edit" constraints="ORDER BY name" />
</body>
</html>
Previous: HTML Tag Reference | Example Template