Set up a dynamic survey

Asked

Viewed 891 times

1

How to do a filter search in the database using this example below:

The bank variables are:

Nome Professor T | Matricula T |Nome Professor S | Matricula S | Nome Professor A | Matricula A | Turma | Ano | Unidade | Modalidade | Tipo do Professor .

Obs: the variable Type would show in the research table which type of teacher " A S or T".

Teachers may vary in type depending on the last 4 variables in the database.

How so?

The teacher may be T in one Unit and in another he may be S.

Then in the research field when typing the name of the teacher or matricula, the survey would show the following table with the data :

Professor | Matricula | Unidade |  Modalidade | Ano | Turma | Tipo do Prof.

Any idea how you assemble this research ? "Any doubts and only question"

The parts in already arrived:

A Html :

<!DOCTYPE html>
<html>
<script>
</script>

<head>
  <title>WEB VIDEO AULAS</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  <!-- Latest compiled and minified CSS -->


</head>

<body>
  <br/> <br/> <br/> <br/> <br/>
  <div class="container">

    <div class="row">
      <div class="col-lg-3">
        <div class="input-group">
          <input type="text" class="form-control" size="35" id="palavra" placeholder="Digite seu nome ou sua matrícula.." required />
          <span class="input-group-btn">
                            <button class="btn btn-blue" id="buscar" type="button">Buscar</button>
                        </span>
        </div>
      </div>
    </div>
    <div id="dados"></div>
  </div>
  <link rel="stylesheet" href="/SLP/css/css/CDTpag2.css">
  <script>
    $('#buscar').click(function() {
      if ($("#palavra").val().length < 1) {
        Alert("digite uma palavra")
        return false;
      } else {
        buscar($("#palavra").val());
      }
    });

    function buscar(palavra) {
      var page = "/SLP/css/css/busca.php";
      $.ajax({
        type: 'POST',
        dataType: 'html',
        url: page,
        beforeSend: function() {
          $("#dados").html("Carregando...");
        },
        data: {
          palavra: palavra
        },
        success: function(msg) {
          $("#dados").html(msg);
        }
      });
    }


    $('#buscar').click(function() {
      buscar($("#palavra").val())
    });
  </script>
  </br>
  </br>
  </br>
  </br>
  </br>
  </br>
  </br>
  </br>

  <link rel="stylesheet" href="/SLP/css/css/voltar.css">
  <a href="Pesquisa" class="bt btn-blue">Limpar</a>
  <br/>
  <link rel="stylesheet" href="/SLP/css/css/voltar.css">
  <a href="Sistema de Lotação" class="bt btn-blue">Voltar</a>
</body>

</html>

And PHP :

<?php header('Content-Type: text/html; charset=iso-8859-1');?>
<?php
 $host = "localhost";
   $user = "root";
   $pass = "";
   $banco = "slp";
   $conexao = mysqli_connect($host, $user, $pass) or die(mysqli_error());
   mysqli_select_db($conexao, $banco) or die(mysqli_error($conexao));

$palavra = $_POST['palavra'];

$sql = mysqli_query($conexao,"SELECT * from cadastros WHERE nomeProfEfetivo LIKE '%".$palavra."%' OR matricula LIKE '%".$palavra."%'");
$row = mysqli_num_rows($sql);
?>
  <section class="panel col-lg-9">

    <header class="panel-heading">
      <br/><br/>

    </header>
    <?php
    if($row>0){
    ?>
      <table class="table table-striped table-advance table-hover">
        <tbody>
          <tr>
            <th><i class="icon_profile"></i> Professor</th>
            <th width="15"><i class="icon_profile"></i> Matricula</th>
            <th><i class="icon_mail_alt"></i> Unidade</th>
            <th width="5"><i class="icon_profile"></i> Modalidade</th>
            <th width="5"><i class="icon_mail_alt"></i> Ano</th>
            <th width="10"><i class="icon_profile"></i> Turma</th>
            <th width="10"><i class="icon_mail_alt"></i> Turno</th>
            <th width=""><i class="icon_mail_alt"></i> Tipo do Prof.</th>
          </tr>
          <?php 
            while($linha = mysqli_fetch_assoc($sql)){
            ?>
          <tr>
            <td width="15">
              <?=$linha['nomeProfEfetivo'];?>
            </td>
            <td width="15">
              <?=$linha['matricula'];?>
            </td>
            <td width="15">
              <?=$linha['unidade'];?>
            </td>
            <td width="15">
              <?=$linha['modalidade'];?>
            </td>
            <td style="text-align:center">
              <?=$linha['ano'];?>
            </td>
            <td style="text-align:center">
              <?=$linha['turma'];?>
            </td>
            <td>
              <?=$linha['turno'];?>
            </td>
            <td style="text-align:center">
              <?=$linha['tipo']; ?>
            </td>


          </tr>

          <?php }?>
        </tbody>
      </table>

      <?php 
				   
	}else{?>
      <h4>Nao foram encontrados registros com esta palavra.</h4>
      <?php }?>
  </section>

  • 1

    Can you explain what you’ve already done and what part you couldn’t get through?

  • See you upstairs enter the codes from where I’ve already arrived. Part that can not advance and in tabala insert several variable in a luga only in the table ex: the name of the teacher I can only boot if it is a name of a single type..

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.