From: angelo.rigo@globo.com
To: pgsql-php@postgresql.org
Subject: records retrieval
Date: Thu, 1 Aug 2002 17:01:27 -0300
Message-ID: <3D3EEC5F00026729@riosf05.globoi.com> (raw)
hi
How can i display the first 20 results at a time and give a link to the
next records i do have on the database?
i am using this code below but give me errors
Wrong parameter count for pg_fetch_array()
anybody has a sample file working?
thank?s in advance!
<?php
$conn = pg_connect("dbname=sondagem user=postgres");
$busca = "SELECT nome, data FROM aprovados order by nome asc";
$total_reg = "10"; // número de registros por página
if (!$pagina) {
$pc = "1";
} else {
$pc = $pagina;
}
$inicio = $pc - 1;
$inicio = $inicio * $total_reg;
$limite = pg_exec("$busca LIMIT $inicio,$total_reg");
$todos = pg_exec("$busca");
$tr = pg_numrows($todos); // verifica o número total de registros
$tp = $tr / $total_reg; // verifica o número total de páginas
while ($dados = pg_fetch_array($limite)) { // vamos criar a visualização
$nome = $dados["nome"];
echo "Nome: $nome<br>";
}
$anterior = $pc -1; // agora vamos criar os botões "Anterior e próximo"
$proximo = $pc +1;
if ($pc>1) {
echo " <a href='?pagina=$anterior'><- Anterior</a> ";
}
echo "|";
if ($pc<$tp) {
echo " <a href='?pagina=$proximo'>Próxima -></a>";
}
?>
________________________________________
A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com.br.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: angelo.rigo@globo.com
Subject: Re: records retrieval
In-Reply-To: <3D3EEC5F00026729@riosf05.globoi.com>
References: <3D3EEC5F00026729@riosf05.globoi.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox