Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to implement the task in PHP/HTML code: using the Sakila database, what woul

ID: 3711426 • Letter: H

Question

How to implement the task in PHP/HTML code: using the Sakila database, what would the query be to allow a user to select a category and display the movies in that catefory to the user and display other suggested categories after.

MariaDB [sakila]> use sakila; Database changed MariaDB [sakila]> show tables; Tables in sakila actor actor info address category | city country customer customer_list film film actor film_category film list film_text | inventory | language nicer_but_slower_film_list | payment rental sales by film category sales_by_store staff staff 1ist store 23 rows in set (e.00 sec) MariaDB [sakila]> use category; ERROR 1049 (42000): Unknown database "category MariaDB [sakila]> select from category lcategory_id | name | last_update 1 I Action 2 Animation 2006-02-15 04:46:27| 3 Children 2006-02-15 04:46:27|I 4Classics 2006-02-15 04:46:27 |2006-02-15 04:46:27|

Explanation / Answer

If you have any doutbs, please give me comment...

<?php

$username = "";

$password = "";

$con = mysql_query("localhost", $username, $password);

mysql_select_db("sakila", $con);

$query = mysql_query("SELECT * FROM category", $con);

$str = "";

while($row = mysql_fetch_array($query, $con)){

$str .= "<option name='".$row['category_id']."'>".$row."</option>";

}

if(isset($_POST['category_id']) && !empty($_POST['category_id'])){

$query2 = mysql_query("SELECT * FROM film f, filmcategory fc WHERE f.f_id=fc.f_id and fc.category_id='".$_POST['category_id']."'", $con);

echo "<h3>The movies are: </h3>";

while($row2 = mysql_fetch_array()){

echo "<p>".$row2['film_name']."</p>";

}

}

?>

<form method="POST">

Select Category: <select name="category_id">

<option>Select</option>

<?=$str;?>

</select>

<input type="sumbit" value="Get Movies" />

</form>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote