Monday, 31 May 2021

PHPS29

 29]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)(PHP 7)

 <html>

<body>

 <form action="s29.php" method="POST">

<table border="1">

<tr><td><input type="radio" name="rad" value="1"></td>

<td>Enter Actor Name : <input type="text" name="aname"></td/></tr>

 

<tr><td><input type="radio" name="rad" value="2"></td>

<td>Enter Movie Information:</td>

<td>Movie name :  <input type="text" name="mname1"></td>

<td>Release Year : <input type="text" name="ryear1"></td>

</tr>

 

<tr><td><input type="radio" name="rad" value="3"></td>

<td>Update Movie Release Year</td>

<td>Enter Moive Name: <input type="text" name="mname"></td>

<td>Enter updated year: <input type="text" name="ryear"></td></tr>

<tr><td><input type="submit" name="submit" value="Submit"></td></tr>

 </table>

</form>

</body>

</html>

  

S29.php

 <?php

$database="archana2";

$con =mysqli_connect("localhost","root" ,"");

if (!$con)

{

die('Could not connect: ' . mysqli_error());

}

mysqli_select_db ($con,"$database");

 $ch=$_POST['rad'];

switch($ch)

{

case '1':   $aname=$_POST['aname'];

$query="select mname from movie where mno in(select mno from movie_actor where ano in(select ano from actor where aname='".$aname."'))";

$result=mysqli_query($con,$query);

if(!$result)

{

echo "Some error occured";

break;

}

while($row=mysqli_fetch_array($result))

{

echo ''.$row[0].'';

echo "<br>";

}

break;

 case '2':   $mname=$_POST['mname1'];

$ryear=$_POST['ryear1'];

$query="insert into movie values('', '".$mname."', '".$ryear."')";

$result=mysqli_query($con,$query);

if(!$result)

{

echo "Some error occured";

break;

}

echo "Inserted new record successfully <br><br>";

break;

 case '3':   $mname=$_POST['mname'];

$ryear=$_POST['ryear'];

$query="update movie set ryear='".$ryear."' where mname='".$mname."'";

$result=mysqli_query($con,$query);

if(!$result)

{

echo "Some error occured";

break;

}

echo "Updated information successfully";

break;

}

mysqli_close($con);

 ?>