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 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)
ex5setc1.html
<html>
<form method="POST" action="ex5setc1.php">
Enter Actor name<br>
<input type="text" value="" name="aname"><br>
Enter movie no<br>
<input type="text" value="" name="mno"><br>
Enter movie name<br>
<input type="text" value="" name="mname"><br>
Enter release year<br>
<input type="text" value="" name="ryear"><br>
<br>Enter choice<br>
1
<input type="radio" value="1" name="ch">Display movie names<br>
2
<input type="radio" value="2" name="ch">Insert movie information<br>
3
<input type="radio" value="3" name="ch">Update release year of movie<br>
<input type="submit" value="submit" name="submit">
<input type="reset" value="reset" name="reset"><br>
</form>
</html>
ex5setc1.php
<?php
$str1=$_POST['aname'];
$ch=$_POST['ch'];
$str2=$_POST['mname'];
$str3=$_POST['ryear'];
$n=$_POST['mno'];
echo"$str1";
echo"$ch";
$conn_str="host=192.168.100.10 port=5432 dbname=tybcs8 user=tybcs8";
$conn=pg_connect("$conn_str");
if(!$conn)
{
echo"Connection Fail.";
}
else
{
switch($ch)
{
case 1:
$q="select mname from actor,movie,m_a where actor.ano=m_a.ano and movie.mno=m_a.mno and aname='$str1'";
$rs=pg_query($conn,"$q");
if(!$rs)
{
echo" an error<br>";
}
echo"<table border=2>";
echo"<tr>";
echo"<th>Movie name</th>";
echo"</tr>";
while($row=pg_fetch_assoc($rs))
{
echo"<tr>";
echo"<td>$row[mname]</td>";
echo"</tr>";
}
echo"</table>";
break;
case 2:
$q="insert into movie values($n,'$mname',$ryear)";
$rs=pg_query($conn,"$q");
if(!$rs)
{
echo" an error<br>";
}
else
{
echo"succesfully";
}
break;
case 3:
$q="update Movie set release_date=2000 where m_name='$mname1'";
$rs=pg_query($conn,"$q");
if(!$rs)
{
echo "An error occurred.<br>";
}
else
{
echo"succesfully update";
}
break;
}
}
?>
0 Comments
If anyone has Doubts or suggestions please let me know