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

$campo = $_POST["campo"];
$valor_campo = $_POST["$campo"];

$sql = "select i.*, u.nome unidade_pretendida from inscricoes i left join unidade u on u.id = i.unidade where i.$campo LIKE '%$valor_campo%' order by id";

$res = mysqli_query($conexao,$sql ) or die( 'Erro na query: <BR>' . $sql . '<BR>' . mysqli_error() );
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.txt_form {	font-size: 9px;
	font-weight: bold;
}
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
-->
</style>
<title>Relatório</title></head>

<body>
<table width="100%" border="1">
  <tr>
  	<td>Nº da Inscrição</td>
    <td>Nome</td>
    <td>Email</td>
	<td>Serie pretendida</td>
	<td>Escola de Origem</td>
	<td>Unidade Pretendida</td>
	<td>Telefone</td>
    <td>Turno</td>
    <td>Ações</td>
  </tr>
<?php
while ($row = mysqli_fetch_array($res)){
?>
  <tr>
  	<td><?php echo $row["inscricao"];?></td>
    <td><?php echo $row["nome"];?></td>
	<td><?php echo $row["email"];?></td>
	<td><?php echo $row["serie_ano"];?></td>
	<td><?php echo $row["origem"];?></td>
	<td><?php echo $row["unidade_pretendida"];?></td>
    <td><?php echo $row["tel"];?></td>
    <td><?php echo $row["horario"];?></td>
    <td><a href="ver_inscricao.php?id=<?php echo $row['id'];?>"><img src="../images/visualizar.png" border="0" /></a><a href="excluir_inscricao.php?id=<?php echo $row['id'];?>"><img src="../images/excluir.png" border="0" /></a></td>
  </tr>
<?php } ?>
</table>
<p><strong>Total de Inscritos: </strong><?php echo mysqli_num_rows($res);?></p>

</body>
</html>
