Tenho um serio problema na páginação, pois estou aprendendo e ja tentei varios códigos dados no FORUM mais só esse até agora quase chegou lá.

Quando faço a busca ele mostra 3 registros com link no fim assim:
1 | 2 | 3 |

Pois existem apenas 6 e no código coloquei para mostrar 3 por página, ai o correto tem que ser 1 | 2 | ok registros. :ok:
Quando clica no 1 | ele mostra apenas mais um registro e quando clica no | 2 | ou | 3 | ele mostra uma pánina em branco com o link 1 | que quando clica-do recarrega a mesma pagina em branco.
Só para não ter dúvidas sobre o código colocarei ele abaixo OK: :ok:
<? $conec; $bco; $conectou = 0; include "conexao.php"; if ($conectou) { $sql = "select * from tb_imoveis where para = '$txt_para'"; $regsporpg = 3; if ($txt_tipo != "") $sql .= " and tipo = '$txt_tipo' "; if ($txt_bairro != "") $sql .= " and bairro = '$txt_bairro' "; if ($txt_dorm == "1") $sql .= " and dorm = 1 "; if ($txt_dorm == "2") $sql .= " and dorm in (2,3) "; if ($txt_dorm == "4") $sql .= " and dorm in (4,5) "; if ($txt_dorm == "5") $sql .= " and dorm >= 5 "; if ($txt_preco == "1") $sql .= " and preco between 100.00 and 200.00"; if ($txt_preco == "2") $sql .= " and preco between 200.00 and 300.00"; if ($txt_preco == "3") $sql .= " and preco between 300.00 and 500.00"; if ($txt_preco == "4") $sql .= " and preco between 500.00 and 800.00"; if ($txt_preco == "5") $sql .= " and preco between 800.00 and 1000.00"; if ($txt_preco == "6") $sql .= " and preco between 1000.00 and 5000.00"; if ($txt_preco == "7") $sql .= " and preco between 5000.00 and 10000.00"; if ($txt_preco == "8") $sql .= " and preco between 10000.00 and 50000.00"; if ($txt_preco == "9") $sql .= " and preco between 50000.00 and 100000.00"; if ($txt_preco == "10") $sql .= " and preco >= 100000.00 "; if ($pg == "") $pg = 1; $pg2 = ($pg - 1) * $regsporpg; $sql1 = $sql . " LIMIT $pg2, $regsporpg "; $res = mysql_query($sql1,$conec) or die (mysql_error()); while ($row = mysql_fetch_array($res)) { $cod = $row['cod']; $para = $row['para']; $tipo = $row['tipo']; $bairro = $row['bairro']; $dorm = $row['dorm']; $banhe = $row['banhe']; $suit = $row['suit']; $garag = $row['garag']; $m2 = $row['m2']; $preco = $row['preco']; $inform = $row['inform']; $foto = $row['foto']; ?> <body link="#000000" vlink="#000000"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <table width="372" border="0" align="center" cellpadding="0" cellspacing="1"> <tr bgcolor="#666666"> <td width="144" rowspan="2" align="left"> <div align="right"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Cod.:</font></strong></font></div></td> <td width="126" rowspan="2" align="left"> <div align="left"><font color="#FFFFFF"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <?php echo $cod; ?> ...... Código sem importancia <tr> <td align="left" bgcolor="#CCCCCC"> <div align="right"><font color="#666666"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Foto:</font></strong></font></div></td> <td colspan="2" align="left" bgcolor="#EAEAEA"> <div align="left"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <?php if ($foto != "") { ?> <a href="http://localhost/imobiliaria/figuras/<? echo $foto; ?>" target="_blank">Ver foto.</a> <? } ?> </font></strong></div></td> </tr> </table> <p align="center"></table> <? } //fecha conteudo $res2 = mysql_query($sql,$conec) or die (mysql_error()); $qtdpgs = ceil((mysql_num_rows($res2) / $regsporpg)); while ($pagina <= $qtdpgs) { $pagina = $pagina + 1; echo "<a href=".$PHP_SELF."?txt_cod=".$cod."&txt_tipo=".$tipo."&txt_para=".$para."&txt_bairro=".$bairro."&txt_dorm".$dorm."&txt_preco=".$preco."&pg=".$pagina."> $pagina </a> |"; } } //fecha conectou else { echo "Nenhum imóvel encontrado nesse perfil."; echo "<br><a href='javascript:history.go(-1)'><< Voltar</a><br>"; } //fecha else ?> <p align="center"> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href='javascript:history.go(-1)'><< Voltar</a></font></font></p>
Aguém ai se hablita a resolver?
