Skip to content

Instantly share code, notes, and snippets.

@axilleas
Created October 14, 2014 17:11
Show Gist options
  • Save axilleas/955d9b2409adb40908aa to your computer and use it in GitHub Desktop.
Save axilleas/955d9b2409adb40908aa to your computer and use it in GitHub Desktop.
maellak php
<html>
<body>
<form action="movies.php" method="post">
<p>Pick Category
<select name="catMovie">
<option value="">Select...</option>
<option value="comedy">Comedy</option>
<option value="drama">Drama</option>
<option value="horror">Horror</option>
</select>
Search: <input type="text" name="search">
<input type="submit">
</form>
</body>
</html>
<html>
<body>
<?php
$comedy=array("The Hangover","Knocked Up","Due Date");
$drama=array("The Shawshank Redemption","The Green Mile","Requiem for a Dream");
$horror=array("Halloween","The Conjuring","The Shining");
$movies=array("comedy"=>$comedy, "drama"=>$drama, "horror"=>$horror);
foreach($movies[$_POST['catMovie']] as $curMovie) {
if (strpos($curMovie, $_POST["search"]) !== false) {
$found[] = $curMovie;
}
}
if (count($found) === 0) {
echo "No movies found. Sorry pal :/";
} else {
foreach ($found as $var) {
echo $var . "</br>";
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment