How To Edit Data on Edit.php Page With The Help of GET () Method
1 First we receive id on edit.php page from data fetch table page like below.
<form action="edit.php?id=<?php echo $id; ?>" method="post" enctype="multipart/form-data">
<input type="image" src="images/icon/icon.png" width="50" id="editm" name="editm" value="<?php echo $data['id'];?>" placeholder="Movie Name" required="">
<input type="hidden" id="idedit" name="idedit" value="<?php echo $data['id'];?>" placeholder="Movie Name" required="">
</form>
2 Then receive data from DB table with help of id like below and then run update query for update data in database like below example.
<?php
include("config.php");
$id = isset($_GET['id']) ? $_GET['id'] : '';
$query = "SELECT * from school_classmaster where id='".$id."'";
$result = mysql_query( $query) ;
$row = mysql_fetch_array($result);
?>
<?php
if(isset($_POST['submit']) )
{
echo $update="UPDATE `school_classmaster` SET `name` = '".$_POST['name']."', `section` = '".$_POST['section']."', `student` = '".$_POST['student']."' WHERE `id` = '".$_POST['id']."'";
$update1=mysql_query( $update) ;
$status = "Record Updated Successfully. </br></br>
<a href='class.php'>View Updated Record</a>";
echo '<p style="color:#FF0000;">'.$status.'</p>';
header('Location: class.php');
}
?>
<form name="form" method="post" action="edit.php">
<p><input type="text" name="name" placeholder="Enter Name"
required value="<?php echo $row['name'];?>" /></p>
<p><input type="text" name="section" placeholder="Enter Section"
required value="<?php echo $section= $row['section'];?>" /></p>
<p><input type="text" name="student" placeholder="Enter Student"
required value="<?php echo $student= $row['student'];?>" /></p>
<input name="id" type="hidden" value="<?php echo $id= $row['id'];?>" />
<p><input name="submit" type="submit" value="update" />
</form>
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
ReplyDeleteRegards,
Dot Net Training Institute in Chennai | Dot Net coaching Institute in Chennai
Selenium Training in Chennai | Selenium Testing Training in Chennai
Manual Testing Training in Chennai | Testing Courses in Chennai
Java Training Institute in Chennai | Core Java Training in Chennai | Java Course and Certification
PHP Course in Chennai | PHP Training Institute in Chennai | PHP Course and Certification