TPI - Conexão PHP com MYSQL - Aula 12
Autor: Professor João Luis Chagas Sanches | Publicado: 2016-11-23T11:03:00-02:00

Na aula 12 temos o arquivo de pesquisa:


pesq_prof_nome.php
===============



&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Listar Dados dos Professores&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&nbsp; &nbsp;&nbsp;
&lt;?php
  include 'config.php'; &nbsp;//para logar no Banco de Dados
  include 'mysqlexecuta.php'; &nbsp;//para executar o script no mysql
  
  $con = conectar();
  mysql_select_db('dbcontrole');

//  $nome= $_POST["txt_nome"];
//  $sql="SELECT * FROM tb_professores where nom_pro like '%$nome%' order by nom_pro";
  $sql="SELECT * FROM tb_professores order by nom_pro ASC";
  
  $res = mysqlexecuta($con,$sql);
 ?&gt;
&nbsp; &nbsp;&nbsp;
&lt;p align="center"&gt;
&lt;tr&gt;
 &lt;td&gt;&lt;div align="right"&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&nbsp; &nbsp;&nbsp;
&lt;tr&gt;
  &lt;td bgcolor=#FFFFC0&gt;&lt;p align="center"&gt;&lt;b&gt;Professores em Ordem Alfabética&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;

&lt;div align="center"&gt;
&nbsp; &lt;table width=750 cellpading=0 cellspacing=0 border=1&gt;
&nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &lt;tr&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;b&gt;Código&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;b&gt;Nome do Professor&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;b&gt;Endereço&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;b&gt;Cidade&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Bairro&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Estado&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Fone&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;strong&gt;Senha&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;b&gt;E-mail&lt;/b&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &lt;/tr&gt;
&nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &lt;?php
&nbsp; &nbsp;  //Exibe as linhas encontradas na consulta
  while ($row = mysql_fetch_array($res)) {
 ?&gt;
&nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &lt;tr&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['cod_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['nom_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['end_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['cid_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['bai_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['est_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['fon_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['sen_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;div align="center"&gt;&lt;?php echo $row['mail_pro'];?&gt;&lt;/div&gt;&lt;/td&gt;
&nbsp; &nbsp; &lt;/tr&gt;
&nbsp; &nbsp;&nbsp;
&nbsp; &nbsp; &lt;?php
&nbsp; }
 ?&gt;
&nbsp; &nbsp;&nbsp;
&nbsp; &lt;/table&gt;
&nbsp;&nbsp;
&lt;/div&gt;
&lt;p&gt; &lt;p&gt;

&lt;a href='index.html'&gt;&lt;p align="center"&gt;Voltar para Menu Principal&lt;/p&gt;&lt;/a&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;