<?php
include ("header.php");
include ("connessione.php");
?>

<div class="container-fluid">
Spettacoli in calendario
</div>
<table class="table">
  <thead>
    <tr>
      <th scope="col">Teatro</th>
      <th scope="col">Titolo</th>
      <th scope="col">Autore</th>
      <th scope="col">Regista</th>
	  <th scope="col">Prezzo</th>
      <th scope="col">Data replica</th>
      <th scope="col">Codice replica</th>
    </tr>
  </thead>
 

<?php 
if (isset($_GET["par"])){
	echo "Sei uscito correttamente!";
}

$sql="select t.nome,m.*,r.*
from teatri t, musical m,repliche r
where t.cod_teatro=m.cod_teatro
and m.cod_musical=r.cod_musical";


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

while ($riga=mysqli_fetch_array($ris)){
	
	if(!isset($_SESSION["caricato"])){
	
	$_SESSION["valori"][]=array("nome"=>$riga["nome"],
								"titolo"=>$riga["titolo"],
								"prezzo"=>$riga["prezzo"],
								"data"=>$riga["data_replica"],
								"codice"=>$riga["cod_replica"]);
	}
	echo "
	 <tbody>
    	<tr>
		 <th scope='row'>".$riga["nome"]."</th>
		 <td>".$riga["titolo"]."</td>
		 <td>".$riga["autore"]."</td>
		 <td>".$riga["regista"]."</td>
		 <td>".$riga["prezzo"]."</td>
		 <td>".$riga["data_replica"]."</td>
		 <td>".$riga["cod_replica"]."</td></tr>";	
}
echo "</tbody> </table>";	

$_SESSION["caricato"]=1;


?>

<?php
include ("footer.php");
?>