Write sample PHP code that achieves the following: (i) On the start page, there
ID: 3690128 • Letter: W
Question
Write sample PHP code that achieves the following:
(i) On the start page, there is a box into which people can type a keyword and then press a button.
(ii) After the button is pressed, your PHP code should provide a list of all movies, including their mids, titles, budget, and gross income, where the movie title contains the keyword. Note that you should use the CONTAINS operator if possible, not LIKE.
(iii) On this page, the user should be able to click on a movie, and the PHP should then display the list of actors that acted in that movie, with the aid, name, their wage, and whether they starred in that movie. If possible, return the list sorted alphabetically by name.
Database looks like:
`Acted_In` (`aid`, `mid`, `starring`, `wage`)
`Actor` (`aid`, `aname`)
`Movie` (`mid`, `title`, `budget`, `gross`)
Explanation / Answer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<form method="post" action="movielist.php">
<input type="text" value="gdf" name="keyword" id=" keyword" /><br /><br />
<input type="submit" value="submit"><br /><br />
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------------
movielist.php
<?php
if(!empty($_POST[' keyword '])){
$movies1=$_POST[' keyword '];
echo "$ movies1";
echo “$’Acted_In` (`aid`, `mid`, `starring`, `wage`)”;
echo “$`Actor` (`aid`, `aname`)”;
echo “$`Movie` (`mid`, `title`, `budget`, `gross`)
}
?>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.