Aca te dejo un ejemplo con una base de datos incluida.
<?php
$db = [
'server' => 'localhost',
'user' => 'root',
'password' => '',
'database' => 'test'
];
$users = [];
$datos = [];
$mysqli = new mysqli(
$db['server'],
$db['user'],
$db['password'],
$db['database']
);
if(!$db)
die('imposible conectar a la base de datos');
if(isset($_POST['user']))
{
$user_id = (int)$_POST['user'];
if(empty($user_id))
die('usuario no ingresado');
$result = $mysqli->query("SELECT username FROM usuarios WHERE id = $user_id LIMIT 1");
$user_exists = ($result->num_rows > 0);
$user = $result->fetch_array(MYSQLI_ASSOC);
if(!$user_exists)
die('usuario no existente');
$datos['username'] = $user['username'];
$result->free_result();
$result = $mysqli->query("SELECT * FROM datos WHERE user_id = $user_id LIMIT 1");
$datos += $result->fetch_array(MYSQLI_ASSOC);
$result->free_result();
}
else
{
$result = $mysqli->query("SELECT id, username FROM usuarios");
if(!$result) {
die('hubo un error [' . $mysqli->error . ']');
}
while($row = $result->fetch_assoc())
{
$users[] = $row;
}
$result->free_result();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>select list</title>
</head>
<body>
<?php
if(!empty($datos)) {
echo 'usuario: <strong>' . $datos['username'] . '</strong><br>';
echo '<table>
<tr>
<th>nombre</th>
<th>apellido</th>
<th>edad</th>
<th>lenguajes</th>
</tr>
<tr>
<td>' . $datos['nombre'] . '</td>
<td>' . $datos['apellido'] . '</td>
<td>' . $datos['edad'] . '</td>
<td>' . $datos['lenguaje'] . '</td>
</tr>
</table>';
}
else {
echo '<form method="POST" action="">
<select name="user">';
foreach($users as $user)
echo '<option value="' . $user['id'] . '">' . $user['username'] . '</option>';
echo '</select><br>
<input type="submit" value="enviar">
</form>';
}
?>
</body>
</html>
configura el array $db
$db = [
'server' => 'localhost',
'user' => 'root',
'password' => '',
'database' => 'test'
];
https://db.tt/MeUEqaD1