records retrieval

records retrieval

am 01.08.2002 22:01:27 von angelo.rigo

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!

$conn =3D pg_connect("dbname=3Dsondagem user=3Dpostgres");
$busca =3D "SELECT nome, data FROM aprovados order by nome asc";
$total_reg =3D "10"; // n=FAmero de registros por p=E1gina

if (!$pagina) {
$pc =3D "1";
} else {
$pc =3D $pagina;
}

$inicio =3D $pc - 1;
$inicio =3D $inicio * $total_reg;

$limite =3D pg_exec("$busca LIMIT $inicio,$total_reg");
$todos =3D pg_exec("$busca");

$tr =3D pg_numrows($todos); // verifica o n=FAmero total de registros
$tp =3D $tr / $total_reg; // verifica o n=FAmero total de p=E1ginas

while ($dados =3D pg_fetch_array($limite)) { // vamos criar a visualiza=E7=
=E3o

$nome =3D $dados["nome"];
echo "Nome: $nome
";
}

$anterior =3D $pc -1; // agora vamos criar os bot=F5es "Anterior e pr=F3xim=
o"
$proximo =3D $pc +1;
if ($pc>1) {
echo " ";
}
echo "|";
if ($pc<$tp) {
echo " ";
}
?>

________________________________________
A busca mais veloz e precisa da internet. Acesse agora: http://www.zoom.com=
..br.



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html