sqltemplate
type
attribute, and the action of the user. The whole
point of using Sparse is to be able to recreate the same query using
different types with only one definition, e.g. being able to both
display and edit the data.sqlfield
tags, and in addition Sparse
will also select all primary keys, even if they're not displayed.
They're needed to identify the rows which are edited or deleted.sqltemplate tables
attribute.sqltemplate
constraints
attribute.sqltemplate
limit
attribute.SELECT e.id, e.name FROM employees AS e WHERE e.salary
> 10000 AND e.country='Canada' ORDER BY e.name DESC LIMIT 10;
<?php
include('Sparse.php');
SparseThisPage('username', 'password');
?>
<html>
<h2 align="center">Employee
Database</h2>
<table>
<tr>
<th>Employee
Name</th>
<th>Employee
ID</th>
</tr>
<sqltemplate type="display"
database="myDB" tables="employees AS e" constraints="WHERE e.salary
> 10000 AND e.country='Canada' ORDER BY e.name DESC" limit="10">
<sqlrow>
<tr>
<td><sqlfield name="e.id"
/></td>
<td><sqlfield name="e.name"
/></td>
</tr>
</sqlrow>
</table>
<sqlaction type="prev" /><sqlaction type="next"
/>
</sqltemplate>
</html>
sqlaction
edit tag
has therefore been taken out). As you can see, Sparse can do pretty
much anything basic SQL can do!sqlaction
buttons, prev and next. These allow
the user to cycle through the displayed results. The limit defined here
is 10, but
Sparse can display the first 10, the second 10, etc. You can also use sqlnavigation
to print a full page-by-page list of links. Note that you can navigate
the data when
editing it as well as displaying it!constraints
attribute. For example, all form data (both GET and POST) is put in the
associative array $_REQUEST. So if your URL looks like this: http://www.mydomain.com/mypage.phtml?name=John
constraints
:constraints='WHERE name="{$_REQUEST["name"]}"'
Previous: Templates - Overview | Templates and Queries | Next: Template Types