calling a variable outside of my while loop is getting an error what is the right way for calling the variable?
$gettingusername = $_GET['username'];
global $connectionDB;
$sql = "SELECT name, lastname FROM admin WHERE username=:username";
$stmt = $connectionDB->prepare($sql);
$stmt->bindValue(':username', $gettingusername);
$stmt->execute();
$result = $stmt->rowCount();
if($result==1){
    while ($fetch = $stmt->fetch()){
        $existingname = $fetch['name'];
        $existinglastname = $fetch['lastname'];
    }
}
<html>
<?php echo $existingname;?> //OUTPUT UNDEFINED VARIABLE HOW TO FIX IT?
<?php echo $existinglastname;?> //OUTPUT UNDEFINED VARIABLE HOW TO FIX IT?
</html>
 
    