Slip 29 - C) Consider the following entities and their relationships Movie (movie_no, movie_name, release_year) Actor (actor_no, name) Relationship between movie and actor is many – many with attribute rate in Rs. Create a RDB in 3NF for the above and solve following Using above database, write PHP scripts for the following:(Hint: Create HTML form having three radio buttons) a) Accept actor name and display the names of the movies in which he has acted. b) Insert new movie information. c) Update the release year of a movie. (Accept the movie name from user)

Solution:

html file -

<html>
<body>
<form action="slip_22.php" method="get">
<h3>Enter Actor Name : <input type=text name=nm> </h3>
<input type=radio name=a value=1>Display Movie Name
<h3>Enter movie no :<input type=text name=m_no>
<h3>Enter movie name :<input type=text name=m_nm>
<h3>Enter release year :<input type=text name=r_yr>
<h3>Enter actor no :<input type=text name=a_no>
<h3>Enter actor name :<input type=text name=a_nm>
<input type=radio name=a value=2>Insert New movie info
<input type=submit value=OK>
</form>
<div id="place"></div>
</body>
</html>

php file -


<?php
$r = $_GET['a'];
$con = mysql_connect("localhost","root","");
$d = mysql_select_db("bca_programs",$con);

if($r == 1)
{ $actor_name = $_GET['nm'];
$q = mysql_query("select m_name from movie,actor,movie_actor where movie.m_no=movie_actor.m_no and actor.a_no=movie_actor.a_no and a_name='$actor_name'");
echo "
Movie Name
";
while($row=mysql_fetch_array($q))
{
echo $row[0]."
";
}
}
else if($r == 2)
{ $m_no = $_GET['m_no'];
$m_name = $_GET['m_nm'];
$r_yr = $_GET['r_yr'];
$a_no = $_GET['a_no'];
$a_name = $_GET['a_nm'];
$q = mysql_query("insert into movie values($m_no,'$m_name',$r_yr)");
$q1 = mysql_query("insert into actor values($a_no,'$a_name')");
echo "Value Inserted";
}
mysql_close();
?>

Post a Comment

0 Comments