The Upper CODE GOTO- http://psmpblogs.blogspot.in/2018/03/how-to-connection-database-full-source.html
SAVE THIS update.php
<?php
include("connect.php");
$id=$_GET['id'];
echo $id;
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<form action="update_process.php" method="get">
<?php
$sql="SELECT * FROM employee_info WHERE id='$id'";
$qry=mysqli_query($con,$sql);
$sl=1;
while($row=mysqli_fetch_array($qry)) {
?>
<input type="hidden" name="id" value="<?php echo $id ?>">
<tr><td>
<input type="text" name="emp_name" value="<?php echo $row['emp_name']; ?>">
</td></tr>
<tr><td>
<input type="number" name="emp_no" value="<?php echo $row['emp_no']; ?>">
</td></tr>
<tr><td>
<input type="text" name="emp_dept" value="<?php echo $row['emp_dept']; ?>">
</td></tr>
<tr><td>
<input type="number" name="emp_sal" value="<?php echo $row['emp_salary']; ?>"> </td></tr>
<tr><td>
<input type="text" name="emp_ph" value="<?php echo $row['emp_phone']; ?>">
</td></tr>
<tr><td>
<input type="text" name="emp_add" value="<?php echo $row['emp_address']; ?>">
</td></tr>
<tr><td>
<input type="submit" name="submit" value="update">
</td></tr>
<?php
}
?>
</form>
</table>
</body>
</html>
THEN SAVE THIS update_process.php
<?php
include('connect.php');
if(isset($_GET['submit'])){
$name=$_GET['emp_name'];
$no=$_GET['emp_no'];
$dept=$_GET['emp_dept'];
$sal=$_GET['emp_sal'];
$ph=$_GET['emp_ph'];
$add=$_GET['emp_add'];
$id=$_GET['id'];
$sql="UPDATE employee_info set emp_name='$name',emp_no='$no',emp_dept='$dept',emp_salary='$sal',emp_phone='$ph',emp_address='$add' WHERE id='$id'";
$qry=mysqli_query($con,$sql);
if($qry){
header("Location:view.php");
}else{
header("Location:update.php?id=<?php echo $id; ?>");
}
}
?>
AND SOME CHANGE OF view.php
<?php
include("connect.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>view</title>
</head>
<body>
<table align="center" border="1">
<thead>
<tr>
<th>SL NO.</th>
<th>NAME</th>
<th>EMP_NO</th>
<th>DEPARTMENT</th>
<th>SALARY</th>
<th>PHONE</th>
<th>ADDRESS</th>
<th>STATUS</th>
<th>UPDATE</th>
</tr>
</thead>
<?php
$sql="SELECT * FROM employee_info";
$qry=mysqli_query($con,$sql);
$sl=1;
while($row=mysqli_fetch_array($qry)) {
?>
<tbody>
<tr>
<td><?php echo $sl; ?></td>
<td><?php echo $row['emp_name']; ?></td>
<td><?php echo $row['emp_no']; ?></td>
<td><?php echo $row['emp_dept']; ?></td>
<td><?php echo $row['emp_salary']; ?></td>
<td><?php echo $row['emp_phone']; ?></td>
<td><?php echo $row['emp_address']; ?></td>
<td><?php echo $row['status']; ?></td>
<td>
<a href="update.php?id=<?php echo $row['id'] ?>">update</a>
</td>
</tr>
<?php $sl++;
} ?>
</tbody>
</table>
</body>
</html>
super se uper wala coding
ReplyDelete