Hello, i'm new around here.
I have a error with my pagination that has a limit and I have a First, Previous, Next, Last button.
I have a query, and when I click on the Next button to show my other results.
The thing is, they query works at a 1º time because it shows me 6results ( witch is correct ), but after I press Next button they 6 results become 7 :S ( I wont want that, I want still to show the next results ( in the first 6 found ) ) .
Notice: Undefined index: Familia in C:\xampp\htdocs*****\paginacaotest.php on line 11
I simply used a where in the query so I can get the info from the $_POST but after I press Next it is like it simply ignore the Where :S.
Can I get a help on this plz =S rly impp..
<?php
$host = "localhost";
$username = "root";
$senha= "";
$banco_dados = "******"; // I have a rly db name d/w
$tabela = "artigos";
$numero_links = "4";
$total_reg = "2";
if(!$pagina) {
$pc = "1";
} else {
$pc = $pagina;
}
$intervalo = $numero_links;
$inicio = $pc-1;
$inicio = $inicio*$total_reg;
mysql_connect($host,$username,$senha);
mysql_select_db($banco_dados);
$search = mysql_escape_string($_POST["Familia"]);
$sql = mysql_query("SELECT * FROM $tabela where Familia LIKE '%".$search."%' ");
$tr = mysql_num_rows($sql);
$sql2 = mysql_query("SELECT * FROM $tabela where Familia LIKE '%".$search."%' LIMIT $inicio,$total_reg");
$tp = ceil($tr/$total_reg);
echo "<font size='1' face='Verdana'>";
echo "Página $pc de $tp<br> Total de registros: $tr<br><br>";
echo "</font>";
echo "<hr>";
while($dados=mysql_fetch_array($sql2)) {
$id = $dados["Nome"];
$nome = $dados["CodigoBarras"];
echo "$id - $nome<br>\n";
}
$aux = $tp/$intervalo;
$aux1 = $pc/$intervalo;
$pi = $aux1 * $intervalo;
if ($pi == "0") {
$pi = "1";
}
$pf = $pi + $intervalo -1;
$anterior = $pi-$intervalo;
if($pc<=$intervalo) {
$anterior = 1;
}
$aux2 = $pi + 1;
if($pi>1) {
$aux = $pi - 1;
$aux2 = $pi + 1;
echo "<hr>";
echo " <<<a href='{$_SERVER['PHP_SELF']}?pagina=1'>Primeiro</a> ";
echo "<<a href='paginacaotest.php?pagina=$aux'><b> Anterior </b></a> ";
}
else
{
echo "<font size='1' face='Verdana'>";
echo "<< Primeiro ";
echo "</font>";
echo "<font size='1' face='Verdana'>";
echo "<< Anterior ";
echo "</font>";
}
for ($pi;$pi<$pf;$pi++)
{
if($pi<=$tp) {
if($pc==$pi) {
echo "<strong><font size='1' face='Verdana'>";
echo "<b>[" . $pi . "]</b> ";
echo "</font></strong>";
} else {
echo "<a href='paginacaotest.php?pagina=" . $pi . "'>" . $pi . "</a> ";
}
}
}
if($pc != $tp){
echo "<strong><font size='1' face='Verdana'>";
echo "<a href='paginacaotest.php?pagina=$aux2'><b> Próximo</b></a> >";
echo " <a href='{$_SERVER['PHP_SELF']}?pagina=$tp'>Ultimo</a> ";
echo "</font></strong>";
}
else
{
echo "<font size='1' face='Verdana'>";
echo " Próximo >>";
echo "</font>";
echo "<font size='1' face='Verdana'>";
echo " Ultimo >>";
echo "</font>";
}
?>
sorry if confuse :S