title: Storing results of a sql query into a variable
body: <p>I am really new at SQL and PHP. Basically I need to store a query result into a variable. I have something like this:</p>
  
  <pre><code>$id = mysql_query("SELECT id FROM users WHERE name = ($user)");
  </code></pre>
  
  <p>So I want <code>$id</code> to have the value of id from table <code>users</code> where the <code>name</code> field in <code>users table = $user</code> (value of a logged-in user).</p>
  
  <p>May I know how to make this work?</p>