Program 1
<?php
require 'dao.php';
require 'model.php'
?>
<html>
<body>
<br><br><br><br><br><br><br><br><br><br>
<center>
<form method=post action="DeleteStudent.php">
<table border=1>
<tr>
<th>Student Id for Delete</th>
<td><input type=text name=txtid></td>
</tr>
<tr>
<td></td>
<td><input type=submit value=Search name=btnSubmit></td>
</tr>
</table>
</form>
<pre>
<?php
if(isset($_POST['btnSubmit']))
{
$stid=$_POST['txtid'];
$sd=new StudentDAO();
$st=$sd->searchStudent($stid);
?>
<table border=1>
<tr>
<th>Roll No</th><th>Name</th><th>Phy</th><th>Chem</th><th>Maths</th>
</tr>
<?php
echo "<tr>";
echo "<td>".$st->getrno()."</td>";
session_start();
$_SESSION['studid']=$st->getrno();
echo "<td>".$st->getname()."</td>";
echo "<td>".$st->getphy()."</td>";
echo "<td>".$st->getchem()."</td>";
echo "<td>".$st->getmath()."</td>";
echo "<form method=post action=DeleteData.php>";
echo "<td><input type=submit value=Delete></td>";
echo "</form>";
echo "</tr>";
}
?>
</pre>
</table>
</center>
</body>
</html>Program 2
<?php
require 'dao.php'
?>
<?php
session_start();
$stid=$_SESSION['studid'];
$sd=new StudentDAO();
$sd->deleteStudentData($stid);
session_destroy();
?>Program 3
<?php
require 'ormconnect.php';
?>
<?php
class StudentDAO
{
public function insertStudent($st)
{
$M=new MyConnection();
$mycon=$M->getConnection();
echo "Connection sucees<br>";
$sql="insert into studentdata values(?,?,?,?,?)";
$ps=$mycon->prepare($sql);
$ps->bind_param("isiii", $st->getrno(),$st->getname(),$st->getphy(),$st->getchem(),$st->getmath());
echo $ps->execute();
echo " <br>Record inserted....";
$mycon->close();
}
public function deleteStudentdata($rno)
{
$M=new MyConnection();
$mycon=$M->getConnection();
$sql="delete from studentdata where sid=".$rno;
$mycon->query($sql);
echo "<font color=red size=5> Record Deleted</font>";
}
public function searchStudent($rno)
{
$M=new MyConnection();
$mycon=$M->getConnection();
$s=new Student();
$sql="select * from studentdata where sid=".$rno;
$record=$mycon->query($sql);
if(mysqli_num_rows($record)>0)
{
while($row=mysqli_fetch_assoc($record))
{
$s->setrno($row['sid']);
$s->setname($row['sname']);
$s->setphy($row['phy']);
$s->setchem($row['chem']);
$s->setmath($row['math']);
}
}
else
{
echo "<font color=red size=5>Record not found</font>";
}
return $s;
}
}
?>