Questions PHP, SQL
Questions PHP, SQL
Answer:-
Php:-
<?php
$c=pg_connect("host=192.168.100.252 dbname=tydb3 user=ty3");
if(!$c)
echo 'not connected';
else
echo "done \n";
$e=$_GET['t1'];
$q=pg_query("update comm set status ='not done' where cno in (select cno
from e_c where eno
in (select eno from event where title='0'));");
if(!$q)
echo "not updated";
else
echo "\n updated!";
?>
Html:-
<!DOCTYPE html>
<html>
<head><title>Assign 6 set a q1</title></head>
<body>
<form name=f1 method=get action=http://192.168.100.252/ty2/ass6a1.php>
Enter title: <input type=text name=t1>
<input type=submit value=Update>
</form>
</body>
</html>
------------------------------------------------------------------------------------------------------------
---------------
Answer:-
StudCom.html
<html>
<body>
<form method="get" action="studcomp.php">
<fieldset>
<legend>Enter Competition Name :</legend><br>
<input type="text" name="cnm"><br><br>
</fieldset>
<div align="center">
<input type="submit" value="Show Result">
</div>
</form>
</body>
</html>
StudCom.php
<?php
$cnames=$_GET['cnm'];
$hn="localhost";
$un="root";
$pass="";
$db="students";
$link=mysqli_connect($hn,$un,$pass,$db);
if(!$link)
{
die('Connection Failed:'.mysqli_error());
}
//$sql="SELECT * FROM student WHERE CNo IN (SELECT CNo FROM
competition WHERE CName = '".$cname."')";
$sql="select * from student,competition,studcomp where
student.Sid=studcomp.Sid and competition.CNo=studcomp.CNo and rank='1'
and CName='".$cnames."'";
$res=mysqli_query($link,$sql);
if(mysqli_num_rows($res)>0)
{
while($row=mysqli_fetch_assoc($res))
{
echo"Stud No : ".$row['Sid']."<br>"." Name : ".
$row['SName']."<br>";
echo"Class : ".$row['SClass']."<br>";
echo"--------------------------"."<br>";
}
}
else
{
echo"error";
}
mysqli_close($link);
?>
------------------------------------------------------------------------------------------------------------
---------------
<!DOCTYPE html>
<html>
<head><title>Assign 6 set b q1</title></head>
<body>
<form name=f1 method=get action=http://192.168.100.252/ty2/ass6b1.php>
Enter name: <input type=text name=t1>
<input type=submit value=Show>
</form>
</body>
</html>
<?php
$c=pg_connect("host=192.168.100.252 dbname=tydb2 user=ty2");
if(!$c)
echo "not connected";
else
echo "done";
$t=$_GET['t1'];
$q=pg_query("select * from property where oname='".$t."';");
while($rs=pg_fetch_array($q))
{
echo "<br>Name: ".$rs[3]."<br>Property: ".$rs[1];
echo "<br>-----------";
}
?>