function DatabaseHandler::get_student_name

6.x DatabaseHandler.php DatabaseHandler::get_student_name($cwid, $bool_include_cwid = FALSE)

Returns the student's first and last name, put together. Ex: John Smith or John W Smith.

Parameters

int $student_id:

Return value

string

File

classes/DatabaseHandler.php, line 1292

Class

DatabaseHandler

Code

function get_student_name($cwid, $bool_include_cwid = FALSE) {

  // Let's perform our queries.
  $res = $this->db_query("SELECT f_name, l_name FROM users 
                      WHERE cwid = ?                      
                      AND is_student = 1 ", $cwid);

  $cur = $this->db_fetch_array($res);
  $name = $cur ["f_name"] . " " . $cur ["l_name"];

  // Force into pretty capitalization.
  // turns JOHN SMITH into John Smith 
  $name = trim(ucwords(strtolower($name)));

  if ($bool_include_cwid) {
    $name .= " ($cwid)";
  }


  return $name;
}