Skip site navigation (1) Skip section navigation (2)

Paging results from a query

From: Anatole Laffreux <gedeon3329(at)yahoo(dot)fr>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Paging results from a query
Date: 2012-03-04 09:53:39
Message-ID: 1330854819.57394.YahooMailNeo@web29213.mail.ird.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
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

Responses

pgsql-novice by date

Next:From: Frank BaxDate: 2012-03-04 12:21:23
Subject: Re: Paging results from a query
Previous:From: Tareq AljabbanDate: 2012-03-03 20:12:55
Subject: initDB - storage manager issues

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group