<?php
$result = sesam_query("SELECT * FROM phone\n" .
" WHERE LASTNAME='" . strtoupper($name) . "'\n" .
" ORDER BY FIRSTNAME", 1);
if (!$result) {
/* ... error ... */
}
// print the table in backward order
echo "<table border=\"1\">\n";
$row = sesam_fetch_row($result, SESAM_SEEK_LAST);
while (is_array($row)) {
echo "<tr>\n";
for ($col = 0; $col < $row["count"]; ++$col) {
echo "<td>" . htmlspecialchars($row[$col]) . "</td>\n";
}
echo "</tr>\n";
// use implied SESAM_SEEK_PRIOR
$row = sesam_fetch_row($result);
}
echo "</table>\n";
sesam_free_result($result);
?>