Wednesday, 27 December 2017

AWT-Slip19

1Write a PHP script to accept a string and then display each word of string in reverse order.     (use concept of self processing form)                                                                          

<html>
<head>
</head>
<body>


<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
Name: <input type="text" name="aname"><br>
<input type=submit name="ok">

</form>
</body>
</html>

<?php


if(isset($_POST['ok']))
{
$q=$_POST["aname"];
echo strrev($q);
}
?>

2)Consider the following relational database:
Project (P_Group_No, Project_Title)
Student (Seat no, Name, Class, P_Group_No)
Write a PHPscript to accept project title and display list of students those who areworking in a particular project


Slip19.html
<html>
<head>
</head>
<body>
<form action="slip19.php" method="get">
Project Name: <input type="text" name="ptitle"><br>
<input type=submit name="ok">
</form>
</body>
</html>

Slip19.php

<?php
$database="archana"; //database name
$q=$_GET["ptitle"];
$con=@mysql_connect("localhost","root" ,"");//for wamp 3rd feild is balnk
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database", $con);
//SELECT m.mno,m.mname,m.year FROM `movie` AS m, `actor` AS a WHERE m.mno=a.mno AND a.aname= '$q';
//$result=mysql_query("select * from movie,actor where actor.aname='".$q"'" and movie.mno=actor.mno ;
$result=mysql_query("SELECT * FROM project,students WHERE project.pno=students.pno AND project.ptitle= '$q'");
echo"<table border='1'>";
echo"<tr><th>pno</th><th>sname</th><th>ptitle</th></tr>";

while($row=mysql_fetch_array($result))
{
echo"<tr><td>";
echo $row['pno'];
echo"</td><td>";
echo $row['ptitle'];
echo"</td><td>";
echo $row['name'];
echo"</td></tr>";
}
echo"</table>";
mysql_close($con);

?>