pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feednext and previous links
2+ messages / 2 participants
[nested] [flat]
* next and previous links
@ 2002-08-23 14:34 angelo.rigo@globo.com
2002-08-23 14:36 ` Re: next and previous links Roj Niyogi <niyogi@pghoster.com>
0 siblings, 1 reply; 2+ messages in thread
From: angelo.rigo@globo.com @ 2002-08-23 14:34 UTC (permalink / raw)
To: pgsql-php
Hi
i am trying to make this code below to work
at least i do get a right pagination, going away and coming back with the
links, but no data is displayed
the browser says this lines has a wrong count parameter
while ($dados = pg_fetch_array($limite)) {
this line is followed by these
$nome = $dados["nome"];
echo "Nome: $nome<br>";
}
thank?s in advance !
<?php
$conn = pg_connect("dbname=anyname user=anyuser");
$busca = "SELECT nome FROM aprovados order by nome asc";
$total_reg = "20"; // 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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: next and previous links
2002-08-23 14:34 next and previous links angelo.rigo@globo.com
@ 2002-08-23 14:36 ` Roj Niyogi <niyogi@pghoster.com>
0 siblings, 0 replies; 2+ messages in thread
From: Roj Niyogi @ 2002-08-23 14:36 UTC (permalink / raw)
To: angelo.rigo@globo.com; +Cc: pgsql-php
My obvious first question is whether $limite is getting a value. If
not, it'll think no parameters are being passed.
Roj
pgHoster.com - PostgreSQL Web Hosting
http://www.pghoster.com
angelo.rigo@globo.com wrote:
>Hi
>i am trying to make this code below to work
>at least i do get a right pagination, going away and coming back with the
>links, but no data is displayed
>
>the browser says this lines has a wrong count parameter
>
>while ($dados = pg_fetch_array($limite)) {
>
>this line is followed by these
> $nome = $dados["nome"];
> echo "Nome: $nome<br>";
>}
>
>thank?s in advance !
><?php
>$conn = pg_connect("dbname=anyname user=anyuser");
>$busca = "SELECT nome FROM aprovados order by nome asc";
>$total_reg = "20"; // 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.
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-08-23 14:36 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-23 14:34 next and previous links angelo.rigo@globo.com
2002-08-23 14:36 ` Roj Niyogi <niyogi@pghoster.com>
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