Wednesday, 27 December 2017

AWT-Slip22

   

1) Write a script to keep track of number of times the web page has been accessed.(Use $_SESSION[ ] )      

<?php
session_start();
if(isset($_SESSION['viewer']))
{
 $_SESSION['viewer'] = $_SESSION['viewer']+1;
}else {
 $_SESSION['viewer'] =1;
}
echo "Viewer number : ".$_SESSION['viewer']."<br>";
?>
                                                                                                                                                                                                                                                                      

2)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 two radio buttons)
a)  Accept actor name and display the names of the movies in which he has acted.
b)Insert new movie information

  slip21.html

<html>

<body>

<form action="slip22.php" method="get">

<h3>Enter Actor Name : <input type=text name=nm>   </h3>

<input type=radio name=a value=1>Display Movie Name<br><br>

<h3>Enter movie no :<input type=text name=m_no> </h3>

<h3>Enter movie name :<input type=text name=m_nm></h3>      

<h3>Enter release year :<input type=text name=r_yr>           </h3>

<h3>Enter actor no :<input type=text name=a_no>   </h3>

<h3>Enter actor name :<input type=text name=a_nm>          </h3>

<input type=radio name=a value=2>Insert New movie info<br><br>

<input type=submit value=OK>

</form>

<div id="place"></div>

</body>

</html>

 

slip21.php

 

<?php

$r=$_GET['a'];

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

$d=mysql_select_db("archana",$con);

if($r==1)

{

$actor_name=$_GET['nm'];

$q=mysql_query("select mname from movie,actor,movieactor where movie.mno=movieactor.mno and actor.ano=movieactor.ano and aname='$actor_name'");

echo "<br>Movie Name </br>";

while($row=mysql_fetch_array($q))

{

echo $row[0]."<br>";

}

}

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();

?>