Q:

proper php/html reference to function

i got it to work like this 
Class: 
     class useraccount{
                private $username;
                private $lastname;
                private $firstname;
    public function userProfileView ()
    {
            $varViewUser = mysql_query("SELECT * FROM users");
                $varusername = $_SESSION['username'];
                $varViewUserProfile = mysql_query("SELECT * FROM users WHERE username = '$varusername'");
                      while ($rows = mysql_fetch_array($varViewUserProfile)) {
                      $this->username = $rows['username'];
                      $this->firstname = $rows['user_firstname'];
                      $this->lastname = $rows['user_lastname'];
                      $this->email = $rows['email'];
                    }

            return $this->lastname;
            return $this->firstname;

    } 
  }

HTML:
    First Name : userProfileView(); ?> 
Now how do i reference which value to be shown? 

A:

Variables in PHP are always local to functions.
Suggest you rewrite to
class useraccount{

  private $username;

  public function getUsername()
  {
    return $this->username;
  }

  public function userProfileView ()
  {
    while ($rows = mysql_fetch_array($varViewUser)) {
      $this->username  = $rows['username'];
        $Firstname = $rows['user_firstname'];
        $lastname = $rows['user_lastname'];
        $email = $rows['email'];
    }
  }

  include ('user_functions.php') ;$varuser = new useraccount; echo $varuser->getUsername();

