برای یه کاربر خاص :
کد PHP:
$result mysql_query("SELECT * FROM table_name WHERE username ='ali'");
$r mysql_fetch_array($result);
echo 
$r['id'];