I am trying to add and read email from a database however I have some problems:

1-For adding well it doesn't work: my html page wants for the user to enter TO, SUBJECT and a MESSAGE and the database have: emaiID, emailSubject, emailText, emailDataTime, FK_usernameFrom, FK_usernameTo.
2-For the list of email it works but with some problemas: I want to put it in a table but the titles appears every new list (information).

Code:
function addEmail($email, $user, $subject )
{
	$conn = openDatabase();
	
	$sql = "insert into emails set FK_usernameTo='$user', emailText='$email',  emailSubject='$subject', emailDateTime=now();";
	
	$result = mysqli_query($conn, $sql);
	
	if ($result)
		$message="Email Sent";
	else
		$message="Error sending email";
	
	closeDatabase($conn);
	
	return $message;
} 
 
 
function getEmail($email)
{
	  $resultTable = "<table border='1'>";
  
  $conn = openDatabase();
  
  $sql = "select * from emails where FK_usernameFrom='$email';";
  
  $result = mysqli_query($conn, $sql);
  
  	$formNum=0;
  
  if ($result)
  {
   while ($row = mysqli_fetch_array($result))
   {
    $from=$row['FK_usernameFrom'];
    $emailSubject=$row['emailSubject'];
    $emailDate=$row['emailDateTime'];
    $message=$row['emailText'];
    
    $resultTable .= "<tr><th>FROM</th><th>SUBJECT</th><th>RECEIVED</th><th>DELETED</th></tr><tr><td>$from</td><td><a href='notesOps.php>'$emailSubject</a></td><td>$emailDate</td><td><a href='emailOps.php?delete=$emailID'>Delete<a></td></tr>";
	
	$formNum++;
   
   }
  }
  mysqli_free_result($result);
  closeDatabase($conn);
  
  $resultTable.= "</table>";
  
  return $resultTable;
}