Thread: Paging results from a query

Paging results from a query

From
Anatole Laffreux
Date:
Hello
I have this script and would like to get the results paged like in a search engine. How can I do this ?



<html><body><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
Name</td>
<td>Telephone</td>
<td>Activity</td>
<td>Adress</td>
</tr>
<?php
$db = pg_connect('host=myserver dbname=mydatabase user=postgres password=mypassword');
$query = "SELECT name,telephone,activity,adress FROM mytable where activity like '%restaurant%' and city like 'Boston%'";
$result = pg_query($query);
if (!$result) {
echo "Problem with query " . $query . "<br/>";
echo pg_last_error();
exit();
}
while($myrow = pg_fetch_assoc($result)) {
printf ("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $myrow['name'], htmlspecialchars($myrow['telephone']), htmlspecialchars($myrow['activity']), htmlspecialchars($myrow['adress']));
}
?>
</table></body></html>

Thanks in advance for help






Re: Paging results from a query

From
Frank Bax
Date:
On 03/04/12 04:53, Anatole Laffreux wrote:
> I have this script and would like to get the results paged like in a
> search engine. How can I do this ?


http://archives.postgresql.org/pgsql-sql/2010-05/msg00043.php