Working solution
<?php
include("database.php");
$db=$conn;
function fetch_data(){
global $db;
$query="SELECT * FROM users WHERE username='vii'";
$exec=mysqli_query($db, $query);
if(mysqli_num_rows($exec)>0){
$row= mysqli_fetch_all($exec, MYSQLI_ASSOC);
return $row;
}else{
return $row=[];
}
}
$fetchData= fetch_data();
show_data($fetchData);
foreach($fetchData as $data){
$firstname=$data['udid'];}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Retrieve Contact</title>
</head>
<body>
<input type=text value= <?php echo "sdfsafs".$firstname; ?>
</body>
</html>