<?php

include("header.php");
include("connessione.php");
echo "<table border=1>";

$sql='select c.cognome,c.nome,b.tipo_pagamento,b.quantita,
		r.data_replica,m.titolo,m.autore,m.regista
from clienti c,biglietti b,repliche r,musical m
where c.cod_cliente=b.cod_cliente
and b.cod_replica=r.cod_replica
and r.cod_musical=m.cod_musical
and c.cod_cliente='.$_SESSION["codcliente"];

$ris=mysqli_query($conn, $sql) or die ("query fallita");

$righe=mysqli_num_rows($ris);

if ($righe==0){
	echo "Non ci sono ancora prenotazioni";
}
?>

<div class="container-fluid">
Le mie prenotazioni:
</div>
<table class="table">
  <thead>
    <tr>
      <th scope="col">Cognome</th>
      <th scope="col">Nome</th>
      <th scope="col">Metodo di pagamento</th>
      <th scope="col">Quantità</th>
	  <th scope="col">Data</th>
      <th scope="col">Titolo</th>
      <th scope="col">Autore</th>
      <th scope="col">Regista</th>
    </tr>
  </thead>

<?php

while ($riga=mysqli_fetch_array($ris)){

	echo "<tr>
		 <td>".$riga["cognome"]."</td>
		 <td>".$riga["nome"]."</td>
		 <td>".$riga["tipo_pagamento"]."</td>
		 <td>".$riga["quantita"]."</td>
		 <td>".$riga["data_replica"]."</td>
		 <td>".$riga["titolo"]."</td>
		 <td>".$riga["autore"]."</td>
		 <td>".$riga["regista"]."</td></tr>";
}

echo "</table>";
include('footer.php');
?>