TY_BCA_AWT_SLIP 14_2



14.     Write Ajax program to print Movie details by selecting an Actor’s name. Create table MOVIE and ACTOR as follows with 1 : M cardinality MOVIE (mno, mname, release_yr) and ACTOR(ano, aname).


Html file :

<html>
<head>
<script type="text/javascript">
 function display(a_name)
{       
         // alert("hi");
         var ob=false;
         ob=new XMLHttpRequest();
         ob.onreadystatechange=function()
         {
                     if(ob.readyState==4 && ob.status==200)
                     document.getElementById("place").innerHTML=ob.responseText;           
         }
         ob.open("GET","slip_14.php?a_name="+a_name,true);
         ob.send();
}
</script>
</head>

<body>
Select Actor Name :
<select name="a_name" onchange="display(this.value)">
<option value="">select actor</option>
<option value="Swapnil Joshi">Swapnil Joshi</option>
<option value="Sachit">Sachit</option>
</select>
<div id="place"></div>
</body>
</html>


Php file :

<?php
         $a_name   =   $_GET['a_name'];

         $con    =   mysql_connect("localhost","root","");  
         $d   =   mysql_select_db("bca_programs",$con);   
         $q   =   mysql_query("select movie.m_no,m_name,r_year from movie,actor_slip_14 where a_name='$a_name' && actor_slip_14.m_no=movie.m_no");    //echo $q;

         echo "<table border=1>";
         echo "<tr><th>Movie No</th><th>Movie Name</th><th>Release Year</th></tr>";

         while($row   =   mysql_fetch_array($q))
         {
                     echo "<tr>";
                     echo "<td>".$row[0]."</td>";
                     echo "<td>".$row[1]."</td>";
                     echo "<td>".$row[2]."</td>";
                     echo "</tr>";
         }

         echo "</table>";
?>

1 comment:

  1. Sir please tell me how to Run this program and get an output ?

    ReplyDelete

Note: only a member of this blog may post a comment.