<html>

<head>
<title>Films</title>
<link rel="stylesheet" type="text/css" href="css/guestbookform.css" />
</head>

<body>


<h1>Films</h1>

<form method="LINK" action="insert-film-form.php">
<input type="submit" value="Insert a film">
</form>
<br>

<?php

$con = mysql_connect("localhost","******","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("******", $con);

$result = mysql_query("SELECT * FROM php_films");

echo "<table border='1'>";

$i=0;
while ($row = mysql_fetch_array($result))
{

if ($i % 2 == 0)
{
echo "<tr bgcolor='#A6E0D9'>";
}
else
{
echo "<tr bgcolor='#D7E7F7'>";
}


//Film title
echo "<td width='300'>";
echo "<a href=\"film-details.php?id=";
echo $row['filmid'];
echo "\">";
echo $row['filmtitle'];
echo "</a>";
echo "</td>";

//Film thumbnail
echo "<td width='80' align='center'>";
echo "<a href=\"images/";
echo $row['filmcover'];
echo "\">";
echo "<img width='60' src=\"images/";
echo $row['filmcover'];
echo "\" >";
echo "</a>";
echo "</p>";
echo "</td>"; 

//Update film
echo "<td width='80' align='center'>";
echo "<a href=\"update-film-form.php?id=";
echo $row['filmid'];
echo "\">";
echo ' Update ';
echo "</a>";
echo "</td>";

//Delete film
echo "<td width='80' align='center'>";
echo "<a href=\"delete-film.php?id=";
echo $row['filmid'];
echo "\">";
echo ' Delete ';
echo "</a>";
echo "</td>";

echo "</tr>";
$i++;
}
echo "</table>";

mysql_close($con);

?>

</body>
</html>