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

<body>

<div id="container">

<div id="header">
	<! header picture in css >
</div>
	
<div id="navigation">
	<?php include 'navigation.php'; ?>
</div>
	
<div id="aside">	
	<br><br>
	<form method="LINK" action="films2.php">
	<input type="submit" value="Back to list">
	</form>
</div>
	
<div id="content">

<?php
if(!empty($_POST)) {

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

	mysql_select_db("******", $con);
	$title = $_POST['filmtitle'];
	//decide how you want to process the query - exact or wildcard?
	//$sql="SELECT * FROM films WHERE `filmtitle` = '$title'";
	$sql="SELECT * from php_films WHERE `filmtitle` like '%$title%' ";
	$result = mysql_query($sql);
	echo "We found the following:<hr />";
	
	echo "<table border='1'>";

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

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


//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/film";
echo $row['filmid'];
echo ".jpg\">";
echo "<img width='60' src=\"images/film";
echo $row['filmid'];
echo ".jpg\" >";
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-film2.php?id=";
echo $row['filmid'];
echo "\">";
echo ' Delete ';
echo "</a>";
echo "</td>";

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

mysql_close($con);

} else {
?>

<h1>Search for a film:</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Film title: <input type="text" size="40" name="filmtitle">
<input type="submit" name="Submit" value="Search">
</form>

<?php } ?>

</div>

<div id="footer">
Copyright &#169; Istvan Franko, 2014
</div>
	

</div>
</body>
</html>
	

