back
<?php
require_once('dbConnect.php');
// Includes the connection class file for further use.
class editClass extends dbConnect{
// This class extends the dbConnect class from the dbConnect.php class file.
// This is needed to access the connection variable for further sql query.
public function editFunction($id,$name){
// This is the function which will edit a row of data in the database uniquely identified by $id.
// For this the function takes $id and $name as argument where $name is the edited value passed through a form.
$query="update oop_table set oop_table.name='".$name."' where oop_table.id=".$id;
// Passing the sql query to the variable $query.
$result=$this->con->query($query);
// In dbConnect.php class file, $con variable is set as an object of the readymade mysqli class.
// query is the fuction of this class which takes the sql query as the argument.
if($result){
header('location:index.php');
// In case the query is successful user is redirected to the index page.
}
}
}
?>