In this example we use 3 file for Delete record or Data using Oracle and PHP.
<?php
include_once 'database.php';
$query="SELECT * FROM employee";
$result=oci_parse($conn,$query);
oci_execute($result);
?>
<!DOCTYPE html>
<html>
<head>
<title>Update employee data</title>
</head>
<body>
<table>
<tr>
<td>Employee Id</td>
<td>First Name</td>
<td>Last Name</td>
<td>City</td>
<td>Email id</td>
<td>Action</td>
</tr>
<?php
$i=0;
while($row=oci_fetch_array($result)) {
?>
<tr>
<td><?php echo $row["userid"]; ?></td>
<td><?php echo $row["first_name"]; ?></td>
<td><?php echo $row["last_name"]; ?></td>
<td><?php echo $row["city_name"]; ?></td>
<td><?php echo $row["email"]; ?></td>
<td><a href="update-process.php?userid=<?php echo $row["userid"]; ?>">Update</a></td>
</tr>
<?php
$i++;
}
?>
</table>
</body>
</html>
<?php
$conn=oci_connect("COMMON","ADMIN","172.16.16.20/WETDB");
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
?>
<?php
include_once 'database.php';
if(count($_POST)>0) {
$query = oci_parse($conn, "UPDATE employee SET userid='" . $_POST['userid'] . "', first_name='" . $_POST['first_name'] . "', last_name='" . $_POST['last_name'] . "', city_name='" . $_POST['city_name'] . "' ,email='" . $_POST['email'] . "' WHERE userid='" . $_POST['userid'] . "'");
$result = oci_execute($query, OCI_DEFAULT);
if($result)
{
oci_commit($conn);
echo "Data Updated Successfully !";
}
else{
echo "Error.";
}
}
$query="SELECT * FROM employee WHERE userid='" . $_GET['userid'] . "'";
$result=oci_parse($conn,$query);
oci_execute($result);
$row=oci_fetch_array($result);
?>
<html>
<head>
<title>Update Employee Data</title>
</head>
<body>
<form name="frmUser" method="post" action="">
<div><?php if(isset($message)) { echo $message; } ?>
</div>
<div style="padding-bottom:5px;">
<a href="view.php">Employee List</a>
</div>
Username: <br>
<input type="hidden" name="userid" class="txtField" value="<?php echo $row['userid']; ?>">
<input type="text" name="userid" value="<?php echo $row['userid']; ?>">
<br>
First Name: <br>
<input type="text" name="first_name" value="<?php echo $row['first_name']; ?>">
<br>
Last Name :<br>
<input type="text" name="last_name" value="<?php echo $row['last_name']; ?>">
<br>
City:<br>
<input type="text" name="city_name" value="<?php echo $row['city_name']; ?>">
<br>
Email:<br>
<input type="text" name="email" value="<?php echo $row['email']; ?>">
<br>
<input type="submit" name="submit" value="Submit" class="buttom">
</form>
</body>
</html>