<?php 
session_start();
/*
 * Authors/listingAuthors.php
 * 
 * Copyright 2009, 2018 Pedro Quaresma <pedro@mat.uc.pt>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

require_once('../servidor.php');

$pUtilizador = $_SESSION['utilizador'];
$pSenha = $_SESSION['senha'];
$pTipoUtilizador = $_SESSION['tipoUtilizador'];
if ($pTipoUtilizador=="anonymous" || $pTipoUtilizador=="regular") {// separa por tipo de utilizador
  require($entradaFILE.'headerUsers.php');
  require($entradaFILE.'menuUsers.php');
} 
else {
  require($entradaFILE.'headerAdmins.php');
  require($entradaFILE.'menuAdmins.php');
}
?>

<center>
<h3 class="maketitle">Prover/Drawer Authors listing</h3>
</center>



<?php
require($entradaFILE.'dbLogin.php');
?>

<?php

// cria uma pesquisa
$sql = "SELECT authorId,name
          FROM authors
      ORDER BY authorId";
$resultado = mysqli_query($ligacao,$sql);


// O números de campos obtidos
$ncampos =mysqli_num_fields($resultado);
$nlinhas =mysqli_num_rows($resultado);

// echo "<center>";
// echo "<h4 class='maketitle'>$nlinhas Provers/Drawers Authors</h4>";
// echo "</center>";


print "<p>&nbsp;</p>";
print "<center>";
print "<table border=1>\n";
print "<tr>\n";
print "<th> Name </th><th>&nbsp;</th><th>&nbsp;</th>";
print "</tr>\n\n";
while ($linha = mysqli_fetch_assoc($resultado)){
  print "<tr>\n";
  $pName=trim($linha['name']);
  $pAuthorId=trim($linha['authorId']);
  print " <td align=center>$pName</td>\n"; 
  print " <td>&nbsp;</td>\n";
  print " <td><a href=seedetailsAuthor.php?argumento=$pAuthorId>See details</a></td>\n";
  print"</tr>\n\n";
 }
print "<tr>\n";
print "</table>\n";
print "</center>";
print "<p>&nbsp;</p>";
?>




<?php
  require($entradaFILE.'footer.php');
?>
