Paging of 2 tabs using 1 control variable for page numbering

0

Next, I have a page that has 2 tabs and in each tab there is pagination, the problem is that I need to use the variable "$ pagina " for both tabs as a way to control the page number without changing both the tabs, how would?

Below my code

.cinza{ background: #c8c4c4; height: 22px; color: black; } } 
.claro{ background:#f9f9f9; height:22px; } 
.fonte{ color:white; font-weight:bold; height:25px; }



       <?php
          // conexão com o banco de dados 
            @mysql_connect("localhost","admin","123456"); 
            @mysql_select_db("db_mining");
            $max = 100;
            @$pagina = $_GET['pagina'];



                @$divisao     = $_POST['divisao'];@$_SESSION['divisao'] = $divisao;
                @$demandante  = $_POST['demandante'];@$_SESSION['demandante'] = $demandante;
                @$num_demanda  = $_POST['num_demanda'];@$_SESSION['num_demanda'] = $num_demanda;
                @$assunto     = $_POST['assunto'];@$_SESSION['assunto'] = $assunto;
                @$data_registro = $_POST['data_registro'];@$_SESSION['data_registro'] = $data_registro;




                            //_SESSION['SQL'] = $_SESSION['RETURN'];

                        //if (empty ($busca) or strlen ($busca)< 2 )
                        //{
                        //    echo "<script> alert ('Digite um parâmetro com pelo menos 2 caracteres!') </script>";
                        //    echo "<script> location.href = ('form_busca.php') </script>";
                        //    exit ();
                        //}
                        if(!$pagina){
                            $inicio = 0;
                            $pagina = 1;
                        }else{
                        $inicio = ($pagina - 1) * $max;
                        }

                        if(!$pagina){
                            $inicio = 0;
                            $pagina = 1;
                        }else{
                        $inicio = ($pagina - 1) * $max;
                        }
                        $sqlfiltro = "";
                        $sqlfinal ="SELECT * FROM demandas_mining WHERE ";
                        $cont = 0;
                        if(@$demandante != "" ){
                            if ($cont == 0){
                                $sqlfiltro = "demandante LIKE '%$demandante%'";
                                $sqlfinal .= $sqlfiltro;
                                $cont += 1;
                            } else {
                                $sqlfiltro = "and demandante LIKE '%$demandante%'";
                                $sqlfinal .= $sqlfiltro;
                            }
                        }
                        if(@$divisao != ""){
                            if($cont == 0){
                                $sqlfiltro = "divisao LIKE '%$divisao%'";
                                $sqlfinal .= $sqlfiltro;
                                $cont += 1;
                            }else{
                                $sqlfiltro = " and divisao LIKE '%$divisao%'";
                                $sqlfinal .= $sqlfiltro;
                            }    
                        }
                        if(@$num_demanda != ""){
                            if($cont == 0){
                                $sqlfiltro = "num_demanda LIKE '%$num_demanda%'";
                                $sqlfinal .= $sqlfiltro;
                                $cont += 1;
                            }else{
                                $sqlfiltro = " and num_demanda LIKE '%$num_demanda%'";
                                $sqlfinal .= $sqlfiltro;
                            }
                        }
                        if(@$assunto != ""){
                            if($cont == 0){
                                $sqlfiltro  = "assunto LIKE '%$assunto%'";
                                $sqlfinal .= $sqlfiltro;
                                $cont += 1;
                            }else{
                                $sqlfiltro = " and assunto LIKE '%$assunto%'";
                                $sqlfinal .= $sqlfiltro;
                            }
                        }
                        if(@$data_registro != ""){
                            if($cont == 0){
                                $sqlfiltro = " data_registro_txt LIKE '%$data_registro%'";
                                $sqlfinal .= $sqlfiltro;
                                $cont += 1;
                            }else{
                                $sqlfiltro = " and data_registro_txt LIKE '%$data_registro%'";
                                $sqlfinal .= $sqlfiltro;
                            }
                        }
                        $_SESSION['SQL'] = $sqlfinal." order by id";

                        $sqln = mysql_query($_SESSION['SQL']);                                                    
                          @$num = mysql_num_rows($sqln);
                        if(@$divisao != "" || @$demandante != "" || @$num_demanda != "" || @$assunto != "" || @$data_registro != ""){
                            if($num == 0){
                                print "Até o momento não temos nenhum evento agendado";
                            }else{
                                $total_paginas = ceil($num/$max);
                                print  "Temos ".$num."  demandas cadastradas no site.<br>";
                                print "Listando a página ".$pagina." de ".$total_paginas."!";
                                $sqln = mysql_query($sqlfinal."order by id desc LIMIT ".$inicio.",".$max."");
                                   $num = mysql_num_rows($sqln);
                            }
                        }else{ 
                                $sqln = mysql_query("SELECT * FROM demandas_mining order by id");
                                   $num = mysql_num_rows($sqln);
                                $total_paginas = ceil($num/$max);
                                print  "Temos ".$num."  demandas cadastradas no site.<br>";
                                print "Listando a página ".$pagina." de ".$total_paginas."!";
                                $sqln = mysql_query("SELECT * FROM demandas_mining order by id desc LIMIT ".$inicio.",".$max."");
                                   $num = mysql_num_rows($sqln);

                        }        
                        ?>

       <legend>Demandas Encontradas</legend>
       <?php
          print '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

          <tr>

          <td width="10%" align="center" bgcolor="#000000" class="fonte">.:: Nº ::.</td>

          <td width="20%" align="center" bgcolor="#000000" class="fonte">.:: Nome do demandante ::.</td>

          <td width="13%" align="center" bgcolor="#000000" class="fonte">.:: Divisão ::.</td>

          <td width="20%" align="center" bgcolor="#000000" class="fonte">.:: Data de Registro ::.</td>

          <td width="27%" align="center" bgcolor="#000000" class="fonte">.:: Assunto ::.</td>

          <td colspan="5%" align="center" bgcolor="#000000" class="fonte" width="15%">.:: Ações ::.</td>

          </tr>';
          for($i = 0; $i < $num; $i++){
              $demandante = @mysql_result($sqln, $i, "demandante");
              $divisao = @mysql_result($sqln, $i, "divisao");
              $dt_reg = @mysql_result($sqln, $i, "data_registro_txt");
              $assunto = @mysql_result($sqln, $i, "assunto");
              $id = @mysql_result($sqln, $i, "num_demanda");        
              $n = $i + 1;
              $d = $i % 2;
          if($d == 0){
            $cor = "cinza";
          }else{
            $cor = "claro";
          }
          print '<tr class='.$cor.'>';
          print '<td align="center">'.$id.'</td>';      
          print '<td>'.$demandante.'</td>';                              
          print '<td align="center">'.$divisao.'</td>';                              
          print '<td align="center">'.$dt_reg.'</td>';                          
          print '<td align="center">'.$assunto.'</td>';
          print '<td align="center"><a href="../mining/busca/busca.php?id='.$id.'">Abrir</a></td>';                              
          print '<td align="center"><a href="atualiza_demanda_adm.php?id='.$id.'&pagina='.$pagina.'">Atualizar</a></td>';                              
          print '<td align="center"><a href="atualiza_nota_adm.php?id='.$id.'">Nota</a></td>';
           //print '<td align="center"><a href="deletagenda.php?id='.$id.'">Excluir</a></td>';
          print '</tr>';

          }
          print '</table>';
          print '<div style="text-align:center; margin-top: 30px;">';
          if($pagina != 1){
          print '<a href=../mining/consultar.php?pagina='.($pagina - 1).'><< anterior</a>';
          }else{
          print '<span style="color: #ccc;"><< anterior </span>';
          }
          if (@$total_paginas > 1){ 
            for ($i=1; $i <= $total_paginas; $i++){ 
                if ($pagina == $i){        
                    echo "<span class='al'> [".$pagina."] </span>"; 
                }else{ 
                    echo '<a href=../mining/consultar.php?pagina='.$i.'&tab=1>&nbsp;'.$i."&nbsp;</a>"; 
                }    
            } 
          } 
          if(@$pagina < @$total_paginas){
          print '<a href=../mining/consultar.php?pagina='.($pagina + 1).'&tab=1>próxima >></a>';
          }else{
          print '<span style="color: #ccc;"> próxima >></span>';
          }
          print '</div>';    
          ?>
    
asked by anonymous 16.04.2018 / 22:01

0 answers