public function update($array,$table,$id)//1st paramerter is associative array,2nd is table name,3rd is id
{
$query="UPDATE $table SET ";
foreach($array as $key=>$result)
{
$query.=$key."="."'$result'".","; //here $key is list of column names and $result is the value corresponding then
}
$str=strlen($query)-1; //used to find out index of the last , in the $str field
$temp_query=substr_replace($query," ",$str);//used to replace , with " "
$temp_query.=" WHERE id=".$id;
$status=$this->execute_query($temp_query); //executing the result see previous post for what is execte_query()
return $status;
}