How to create power to filter data by php

0

What I plan to do is make a filter by name, but what happens to me is that it shows me the name list that I need but when I choose one and press the button it refreshes the page but I do not apply the corresponding filter I attached the code to see if you can see something that I could not see thank you.

if($agencia1 == 'RM' || $agencia2 == 'RM' ){ ?>

 <form id="form2" method="post">
                   Seleccione Agencia

                    <?
                        if ($aux == 'Becar Soto Magdalena' || $aux == 'Opazo Carlos' ) {

                            $get1=mysql_query("SELECT DISTINCT avisos.agencia 
                             FROM avisos

                               ");
                        }else{

                            $get1=mysql_query("SELECT DISTINCT avisos.agencia 
                             FROM avisos
                             INNER JOIN agencias ON avisos.agencia = agencias.abrev_agencia
                             WHERE agencias.zona = 'RM'
                               ");
                        }
                    ?>

                    <select id="agenciap" name="agenciap">

          <option value="Todos">Todos</option>
          <?while($row1 = mysql_fetch_assoc($get1))
                {
              $opciones1.='<option value="'.$row1["agencia"].'">'.$row1["agencia"].'</option>';

                }echo $opciones1;?>
                    </select><br>
            <br/>
                <input name="EnviarInfo" class="btn btn-primary btn-block" type="submit" style="width: 25%" value="Filtrar Por Zona"></br>

            <form id="form" method="post">
                Selecione Gestor
             <? $sqltipo="SELECT nom_gestor FROM avisos";
               $consultatipo = mysql_query($sqltipo); ?>

                <select id="gestor" name="gestor">
                <option value="Gestores">Gestores</option>
                <? while($filatipo = mysql_fetch_array($consultatipo)){ ?>
                         <option value="<? echo $filatipo['nom_gestor'] ?>"><? echo $filatipo['nom_gestor'] ?></option>
                <? } ?>
               </select>



            <input name="EnviarInfo2" class="btn btn-primary btn-block" type="submit" style="width: 25%" value="Filtrar por Gestor"></br>
                </form>
    <?php
if ($_POST[EnviarInfo2]) {

    $gestor = $_POST['gestor'];
    $link = mysqli_connect("localhost","pcomp","KneTPuxJ77f4YLNX", "cayas_v3");

}
if($gestor == 'Gestores')
{
$sql123 = "SELECT * , TIME_TO_SEC( TIMEDIFF( NOW( ) ,  'fecha_ingreso' ) ) /3600 AS horas_sla,
(avisos.horas_quiebre - time_to_sec(timediff(NOW(), fecha_quiebre )) / 3600) AS horas_restantes_quiebre
FROM avisos
where estado='Resolviendo CFN' or (estado_anterior_quiebre = 'Resolviendo CFN' and estado='Quiebre') 
order by horas_sla desc";
}
else
{
    $sql123 = "SELECT * , TIME_TO_SEC( TIMEDIFF( NOW( ) ,  'fecha_ingreso' ) ) /3600 AS horas_sla,
           (avisos.horas_quiebre - time_to_sec(timediff(NOW(), fecha_quiebre )) / 3600) AS horas_restantes_quiebre
          FROM avisos where (estado='Resolviendo CFN' or estado_anterior_quiebre = 'Resolviendo CFN' ) and gestor='$gestor' and estado !='Cerrado' order by horas_sla desc";
}
 if ($_POST[EnviarInfo])
{
    $agenciap = $_POST['agenciap'];
$link = mysqli_connect("localhost","pcomp","KneTPuxJ77f4YLNX", "cayas_v3");

if($agenciap == 'Todos')
{
$sql123 = "SELECT * , TIME_TO_SEC( TIMEDIFF( NOW( ) ,  'fecha_ingreso' ) ) /3600 AS horas_sla,
(avisos.horas_quiebre - time_to_sec(timediff(NOW(), fecha_quiebre )) / 3600) AS horas_restantes_quiebre
FROM avisos
where estado='Resolviendo CFN' or (estado_anterior_quiebre = 'Resolviendo CFN' and estado='Quiebre') 
order by horas_sla desc";
}
else
{
    $sql123 = "SELECT * , TIME_TO_SEC( TIMEDIFF( NOW( ) ,  'fecha_ingreso' ) ) /3600 AS horas_sla,
           (avisos.horas_quiebre - time_to_sec(timediff(NOW(), fecha_quiebre )) / 3600) AS horas_restantes_quiebre
          FROM avisos where (estado='Resolviendo CFN' or estado_anterior_quiebre = 'Resolviendo CFN' ) and agencia='$agenciap' and estado !='Cerrado' order by horas_sla desc";
}
$result123 = mysql_query($sql123);
        // Verifica si ha devuelto algún registro
    $num = 1;
    
asked by jeson 22.10.2018 в 14:59
source

0 answers