Created
October 14, 2014 17:11
-
-
Save axilleas/955d9b2409adb40908aa to your computer and use it in GitHub Desktop.
maellak php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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