A litle bit complete answer is here with all ready for use:
$sql = "SELECT `username` FROM `users` WHERE `id` = :id";
$q = $dbh->prepare($sql);
$q->execute(array(':id' => "4"));
$done= $q->fetch();
echo $done[0];
Here $dbh
is PDO db connecter, and based on id
from table users
we've get the username
using fetch();
I hope this help someone, Enjoy!