jcramalho

Listar a tabela professores do MySQL

Dec 2nd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2.   $bd = new PDO('mysql:host=localhost;dbname=engweb2015', 'jcramalho', '4140');
  3.  
  4.   echo "<h1 align='center'>Gestão de Professores</h1>";
  5.   echo "<ul>";
  6.   echo "<li><a href='loadXML.html'>Carregar do XML</a></li>";
  7.   echo "<li><a href='reset.html'>Apagar a tabela</a></li>";
  8.   echo "</ul>";
  9.   echo "<table border='1' style='text-align:center;'>".
  10.   "<tr><th>Código</th><th>Nome</th>".
  11.   "<th>Departamento</th><th>Email</th><th>Ops</th></tr>";
  12.    
  13.     $query = $bd->query("SELECT * FROM Professor");
  14.    
  15.     while ($linha = $query->fetch()){
  16.         echo "<tr><td>".$linha['codigoProf']."</td>";
  17.         echo "<td>".$linha['nome']."</td>";
  18.         echo "<td>".$linha['departamento']."</td>";
  19.         echo "<td>".$linha['email']."</td>";
  20.         echo "<td><a href='alterarProf.php?idProf=".
  21.              $linha['codigoProf']."'>Alterar</a>".
  22.              " <a href='removerProf.php?idProf=".
  23.              $linha['codigoProf']."'>Remover</a>";
  24.         echo "</tr>";
  25.     }
  26.     echo "</table><br/>  <a href='index.html'>Voltar ao ínicio</a>";
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment