TY_BCS_PHP_slip 25_2

Slip no. 25. Write AJAX program to print movie by selecting an actor’s name. create table Movie and Actor with 1:M cardinality as follows:
Movie ( mno, mname, release_year)
Actor( ano, aname)
[USE PostgreSQL]
HTML file :
<script type="text/javascript">
function display()
            ob = new XMLHttpRequest();
            var a = document.getElementById("a").value;
            ob.onreadystatechange = function()
if(ob.readyState == 4 && ob.status == 200)
                        document.getElementById("i").innerHTML = ob.responseText;



Enter Actor Name :<input type=text name=a id=a><br>
<input type=submit value="DISPLAY MOVIE NAME" onclick=display()><br>
<span id=i></span>

PHP file :
$con_string = "host=localhost dbname=bcs_slips port=5432  user=postgres password=nrc";

$con = pg_connect($con_string);

$a = $_GET['a'];
echo $a;
echo "</br>";
$q = "select movie.mno,mname,r_yr from movie,actor where aname='$a' and movie.mno = actor.mno;";
$rs = pg_query($con,$q) or die("Cannot Execute query");

while($row = pg_fetch_row($rs))
echo "$row[0] $row[1] $row[2]\n</br>";


No comments:

Post a comment

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