Slip 9 - B) 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 3 NF. With using three radio buttons (accept, insert, update) Write an AJAX script to accept actor name and display names of movies in which he has acted.

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