function Update($mysqli,$table_name, $form_data, $where_clause='',$v=0){   
  //global $mysqli;
  // check for optional where clause
  $whereSQL = '';
  if(!empty($where_clause)){
    // check to see if the 'where' keyword exists
    if(substr(strtoupper(trim($where_clause)), 0, 5) != 'WHERE')
    {
        // not found, add key word
        $whereSQL = " WHERE ".$where_clause;
    } else
    {
        $whereSQL = " ".trim($where_clause);
    }
  }
  // start the actual SQL statement
  $sql = "UPDATE `".$table_name."` SET ";

  // loop and build the column /
  $sets = array();
  foreach($form_data as $column => $value)
  {
       $sets[] = "`".$column."` = '".$value."'";
  }
  $sql .= implode(', ', $sets);

  // append the where statement
  $sql .= $whereSQL;
       
  // run and return the query result
  if($v==1) {
    echo $sql."<br>";
  }
  return mysqli_query($mysqli,$sql);
}