Ir para conteúdo
Fórum Script Brasil
  • 0

Sistema De Busca Com Paguinaçao


Guest infotec21

Pergunta

Guest infotec21

ola galera estou com problema neste script na parte da paginação

esse o script que não faz a paginaçao

<?php

//maurilio

include("dat/conect.con");

$produtos = $HTTP_POST_VARS[produto];

$produtos = $HTTP_POST_VARS[uf];

$nome = $HTTP_POST_VARS[nome];

//inicio codigo paginação

if (!isset($pag)) // variavel $pg é a pagina atual

$pag = 0;

$inicial = $pag * 3; // este 5 é o número de resultados por tela

####### vai pegar os resultados mesmo...

$pegar = "SELECT * FROM empre WHERE produto LIKE'%$produto%' and uf =$uf' and nomefantazia LIKE '%$nome%' ORDER BY id DESC LIMIT $inicial,3"; // esta variavel $inicial vai ser qual é o registro de inicio

$cad = mysql_query ($pegar);

##### até aqui

##### Aqui vai contar o total de registros para saber o total de paginas que será usado

$contar = "SELECT id FROM empre";

$contarok= mysql_query ($contar);

$total_records = mysql_num_rows($contarok);

$pages = intval($total_records / 3);

?>

<html>

<head>

<title>&gt;&gt; e - busca :: O seu Guia na Net &lt;&lt;</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#000000" text="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="78%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><font face="tahoma" size="2">&nbsp;busca</font></td>

</tr>

<tr>

<td bgcolor="#FFFFFF">&nbsp;</td>

</tr>

<tr>

<td valign="top" height="408">

<table width="83%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td height="283"><font size="2" face="tahoma"><b>Resultado da busca:</b>

Foram encontrados <b><?echo $total_records;?></b> registros, divididos em <b><? if(!$pages){ echo "0"; }else{ echo $pages; }?></b><br>

</font>

<hr size="3" noshade color="#FFD700">

<table width="100%" border="2" cellspacing="0" cellpadding="2" bgcolor="#FFFFFF" bordercolor="#FF9900">

<tr>

<td>

<div align="center"><font color="#000000" size="2" face="tahoma"><b><a href="index.php"><img src="imagens/voltar.gif" width="59" height="22" border="0"></a>

</b></font></div>

</td>

</tr>

</table>

<br>

<?

while ($linha=mysql_fetch_array($cad)) {

$razao = $linha["razaosocial];

$nome = $linha["nomefantasia"];

$ramo = $linha["ramoatividade"];

$produto = $linha["produto"];

$uf = $linha["uf"];

$fax = $linha["fax"];

$fone = $linha["fone"];

$site = $linha["site"];

$email = $linha["email"];

?>

<table width="100%" border="2" cellspacing="0" cellpadding="3" bordercolor="#FFFFFF" bgcolor="#FFCC00">

<tr>

<td height="142">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><font color="#000000" size="2" face="tahoma"><b> <?echo $razao;?>

</b><br>

<?echo $nome;?> <?echo $ramo;?> <br>

<?echo $produto;?> <br>

<?echo $fax;?> / <?echo $fone;?> <br>

<?echo $site;?> <br>

<?echo "$razao";?> <br>

<br>

<a href="http://<?echo $site;?>"><img src="imagens/ico1.gif" width="70" height="27" border="0"></a>

<a href="mailto:<?echo $email;?>"><img src="imagens/ico2.gif" width="74" height="27" border="0"></a>

</font><font color="#000000" size="2" face="tahoma"><br>

</font> <div align="center"></div></td>

</tr>

</table>

</td>

</tr>

</table>

<br>

<?

}

?>

<font size="2"><br>

</font> <font size="2">&nbsp;</font><font size="2"> <br>

</font>

<table width="100%" border="2" cellspacing="0" cellpadding="2" bgcolor="#FFFFFF" bordercolor="#FF9900">

<tr>

<td> <font color="#000000" size="2" face="tahoma"><b>P&aacute;ginas

<img src="IMAGENS/seta_veja.gif" width="6" height="8">

<?

######## criando os links dinâmicos

if ($pg <> 0) {

$url = $pg - 1;

echo "<font face=tahoma size=2 color=ff0000>&nbsp;<a id=mulink href=$PHP_SELF?pg=$url>5 anteriores</a>&nbsp;</font>";

}

else {

echo "&nbsp;";

}

for ($i = 0; $i<($pages + 1); $i++) {

if ($i == $pg) {

echo "&nbsp;&nbsp;<font face=tahoma size=2 color=ff0000><b>$i</b></font>&nbsp;&nbsp;";

}

else {

echo "<font face=tahoma size=2 color=ff0000>&nbsp;&nbsp;<a id=mulink href=$PHP_SELF?pg=$i>$i</a>&nbsp;&nbsp;</font>";

}

}

if ($pg < $pages) {

$url = $pg + 1;

echo "<font face=tahoma size=2 color=ff0000>&nbsp;<a id=mulink href=$PHP_SELF?pg=$url> Próximos 5</a>&nbsp; </font>";

}

else {

echo "&nbsp;";

}

?>

</b></font></td>

</tr>

</table>

</td>

</tr>

<tr>

<td height="82">

<table width="796" border="0" cellspacing="3" cellpadding="3">

<tr bgcolor="#FFFFFF">

<td height="76" colspan="2"><div align="center"><img src="imagens/banner.jpg" width="468" height="60"></div></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</body>

</html>

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...