Displaying a greeting to one user selected from a database I execute the following SQL statement to get back an data object into a variable. 

  try {
    $getUser = $db-&gt;query('select * from user where user.user_id = '.$user_id);
  } catch (Exception $e) {
    echo $e-&gt;getMessage();
    die();
  }


from this I print out the information on the page where necessary e.g. the following:

  &lt;?php
  foreach ($getUser as $user) {
    echo '
    &lt;div class="col-wd-12"&gt;
      &lt;div class="col bodyHead"&gt;Welcome, '.$user['email'].'&lt;/div&gt;
    &lt;/div&gt;
    ';
  }
  ?&gt;


The question is I know the size of the $getUser array to always be one. 
Am I doing this the correct way when returning the information? Is there a better way where I do not need to use a foreach loop everytime.
The question is I know the size of the $getUser array to always be one.


No you don't. You assume it is - and it's probably a safe assumption to make. But actually knowing that user_id is a primary key is the job of the underlying database, not of your application.

You would know that 1 record is returned, if the query you send to the database says "give me one record where user_Id is equal to..." - if your backend is mysql that's done with a LIMIT clause.

Your query is missing a terminating semicolon... but the worst offense is the concatenation of the .$user_id into the WHERE clause. Where's that value coming from? Is there any slightest chance that it might not be containing the value you're expecting, and that concatenating it could result in unexpected SQL statements being injected into your query? If that's the case, then your query might actually be returning all rows, not just one.

See give me parameterized SQL, or give me death! (or many, many, many other online resources) for more details.