Fill SELECT via form (PHP)

0

I have the following code:

<?php
include("conexao.php");

$sql = mysql_query("SELECT COUNT(*) 
FROM escola e
WHERE coordenador IN (SELECT ec.coordenador 
               FROM escola_coordenador ec 
              WHERE ec.coordenador = '1')
AND uf = 'PR' AND situacao = 'contratado'");
$row = mysql_fetch_array($sql); 
$total = $row['COUNT(*)'];
echo $total;

?>

It shows the amount of record in the bank.

I need a form for the user to type: the coordinator number and the UF, and then the amount in total $ appears.

Can anyone help me?

    
asked by anonymous 21.12.2017 / 19:04

1 answer

0

I was able to solve my problem.

I created an index.html file:

<form action="script.php" method="post">
Coordenador <input type=text name=coordenador><br>
Estado (UF): <input type=text name=uf><br>
<input type=submit value="Buscar">
</form>

And a script.php file:

<?php
include("conexao.php");

$coordenador = $_POST["coordenador"];
$uf = $_POST["uf"]

$sql = mysql_query("SELECT COUNT(*) 
FROM escola e
WHERE coordenador IN (SELECT ec.coordenador 
               FROM escola_coordenador ec 
              WHERE ec.coordenador = '$coordenador')
AND uf = '$uf' AND situacao = 'contratado'");
$row = mysql_fetch_array($sql); 
$total = $row['COUNT(*)'];
echo $total;

?>
    
21.12.2017 / 19:26