I execute the following SQL statement to get back an data object into a variable.
try {
$getUser = $db->query('select * from user where user.user_id = '.$user_id);
} catch (Exception $e) {
echo $e->getMessage();
die();
}
from this I print out the information on the page where necessary e.g. the following:
<?php
foreach ($getUser as $user) {
echo '
<div class="col-wd-12">
<div class="col bodyHead">Welcome, '.$user['email'].'</div>
</div>
';
}
?>
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.