Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

First Create Table View to display records similar to my previous article.

                       

View Student Record


RnoSnameBranchFees
1001jaykumar awasthiCS85000EditDelete
1002manishCS56000EditDelete
1003jayCS56000EditDelete



Are you sure you want to update the record

RNO
NAME
BRANCH
FEES
BACK to show record

Are you sure you want to delete the record

RNO
NAME
BRANCH
FEES
BACK
Step1st:-

View Record Code in PHP:-


Create Table first using PHPmyadmin of Student with four-column (rno,sname, branch, fees)


Create HTML View using viewrecord.php

<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
table
{
width:600px;
}
table th
{
background-color:yellow;
color:blue;
font-size: 25px;
}
        table td
{
background-color:orange;
color:black;
font-size: 20px;
text-align: center;
}
</style>
</head>
<body>
<h1>View Student Record</h1>
<hr>
<table border="1">
<tr><th>Rno</th><th>Sname</th><th>Branch</th><th>Fees</th></tr>
<?php
$conn= mysqli_connect('localhost','root','','php12batch');
$res = mysqli_query($conn,"select * from student");
while($x = mysqli_fetch_array($res))
{
  echo "<tr><td>".$x[0],'</td><td>' ,$x[1],'</td><td>',$x[2],'</td><td> ',$x[3],"</td><td><a href='editstudent.php?q=".$x[0]."'>Edit</a></td><td><a href='deletestudent.php?q=".$x[0]."'>Delete</a></td></tr>";

}
?>
</table>


Step2nd:-  Create EditStudent.php


<?php

$rno= $_REQUEST['q'];
$conn= mysqli_connect('localhost','root','','php12batch');
$res = mysqli_query($conn,"select * from student where rno=$rno");
if($x = mysqli_fetch_array($res))
{
?>
<h1>Are you sure you want to update record</h1>
<form action="" method="post">
<table>
<tr><td>RNO</td><td><input type="text" name="txtrno" value="<?php echo $x[0]; ?>"  readonly="true" /></td></tr>
<tr><td>NAME</td><td><input type="text" name="txtsname" value="<?php echo $x[1]; ?>"  /></td></tr>
<tr><td>BRANCH</td><td><input type="text" name="txtbranch" value="<?php echo $x[2]; ?>"  /></td></tr>
<tr><td>FEES</td><td><input type="text" name="txtfees" value="<?php echo $x[3]; ?>"  /></td></tr>
<tr><td></td><td><input type="submit" name="btnupdate" value="Update"/></td></tr>
</table>

</form>

<?php
}
if(isset($_REQUEST['btnupdate']))
{
$r = $_REQUEST['txtrno'];
$n = $_REQUEST['txtsname'];
$b = $_REQUEST['txtbranch'];
$f = $_REQUEST['txtfees'];

$res1= mysqli_query($conn,"update student set sname='$n',branch='$b',fees='$f' where rno='$r'");
if(mysqli_affected_rows($conn)>0)
{
echo "data updated successfully";

}
else
echo "problem in insertion";
}

?>
<a href="TableViewEditDeleteStudent.php">BACK to show record</a>





Create DeleteStudent.php


<?php

$rno= $_REQUEST['q'];
$conn= mysqli_connect('localhost','root','','php12batch');
$res = mysqli_query($conn,"select * from student where rno=$rno");
if($x = mysqli_fetch_array($res))
{
?>
<h1>Are you sure you want to delete record</h1>
<form action="" method="post">
<table>
<tr><td>RNO</td><td><input type="text" name="txtrno" value="<?php echo $x[0]; ?>"  readonly="true" /></td></tr>
<tr><td>NAME</td><td><input type="text" name="txtsname" value="<?php echo $x[1]; ?>"  /></td></tr>
<tr><td>BRANCH</td><td><input type="text" name="txtbranch" value="<?php echo $x[2]; ?>"  /></td></tr>
<tr><td>FEES</td><td><input type="text" name="txtfees" value="<?php echo $x[3]; ?>"  /></td></tr>
<tr><td></td><td><input type="submit" name="btndelete" value="Delete"/></td></tr>
</table>

</form>

<?php
}
if(isset($_REQUEST['btndelete']))
{
$r = $_REQUEST['txtrno'];
$n = $_REQUEST['txtsname'];
$b = $_REQUEST['txtbranch'];
$f = $_REQUEST['txtfees'];

$res1= mysqli_query($conn,"delete from student where rno='$r'");
if(mysqli_affected_rows($conn)>0)
{
echo "data deleted successfully";

}
else
echo "problem in deletion";
}

?>
<a href="TableViewEditDeleteStudent.php">BACK</a>






</body>
</html>



Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post