Wednesday, 27 December 2017

AWT-Slip21


1)Write a PHP program to accept two string from user and check whether entered strings are matching or not.(use sticky form concept)

sticky.php

<html>
<head>
</head>
<body>
<form method="post" action="sticky.php">
<b>Enter String 1</b><input type="text" name="str1" value="<?php if(isset($_POST['str1'])) echo $_POST['str1'];?>" />
<b>Enter String 2</b><input type="text" name="str2" value="<?php if(isset($_POST['str2'])) echo $_POST['str2'];?>" />
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submit" value="true" />
</form>
<?php
if(isset($_POST['submit']))
{
 $s1 = $_POST['str1'];
 $s2 = $_POST['str2'];
 
 if(strcmp($s1,$s2) == 0) { echo "Matching...";}
 else { echo "String not matching...";}
}
?>

</body>

</html>
                                                                                                                                               

2)Consider the following entities and their relationships
Doctor (doc_no, doc_name, address, city, area)
Hospital (hosp_no, hosp_name, hosp_city)
Doctor and Hospital are related with many-many relationship
Create a RDB in 3 NF for the above and solve following
Using above database, write a PHP scriptwhich accepts hospital name and   printinformation about doctors visiting / working in that hospital in tabular format 


slip21.html

<html>
<body>
<form action="slip21.php" method="get">
Enter the name of Hospital name  :  <input type=text name=hname><br>
<input type=submit value=SUBMIT>
</form>
</body>
<html>    


slip21.php

<?php

$database="archana"; //database name
$hname=$_GET['hname'];
$con=@mysql_connect("localhost","root" ,"");//for wamp 3rd feild is balnk
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database",$con);
$result=mysql_query("select * from doctor,hospital,dh where doctor.doc_no=dh.doc_no and hospital.hosp_no=dh.hos_no and hosp_name='$hname'")or die(mysql_error());

echo"<table border='1'>";
echo"<tr><th>dno</th><th>name</th><th>address</th></tr>";
while($row=mysql_fetch_array($result))
{
echo"<tr><td>";
echo $row['doc_no'];
echo"</td><td>";
echo $row['doc_name'];
echo"</td><td>";
echo $row['address'];
echo"</td></tr>";
}
echo"</table>";
mysql_close($con);
?>