My function is not working, though it shows the successful message that the data has been updated. But the data is still the same in the database also.
public function update(){
$mysql = new Mysql();
$query = "UPDATE module SET
modulename = '$this->name',
modulecode = '$this->code',
semesterid = '$this->semester',
departmentid = '$this->department',
programid = '$this->program'
where moduleid = '$this->id';";
$mysql->execute($query);
if($mysql->result){
$mysql->successMessage("Successfully Updated Data");
}
}
if(isset($_POST['update'])){
$module = new Module($_POST);
$module->update();
}
Try to use:
$query = "UPDATE module SET
modulename = '".$this->name."',
modulecode = '".$this->code."',
semesterid = '".$this->semester."',
departmentid = '".$this->department."',
programid = '".$this->program."'
where moduleid = '".$this->id;
I think you are looking for the number of rows affected by the query rather than the result.
Try mysql_affected_rows() to find out if anything was actually updated by the query.