function DatabaseHandler::get_student_name

7.x DatabaseHandler.php DatabaseHandler::get_student_name($cwid, $bool_include_cwid = FALSE)
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 1294

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);
  if ($cur) {
    $name = $cur ["f_name"] . " " . $cur ["l_name"];
  }
  else {
    $name = t("Unknown Student");
  }

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

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


  return $name;
}