title: create array from mysql query php
body: <p>I have a little problem that I don't understand. I have a db that has an owner and type (and more off course). I want to get a list of all the type values that has owner equal to the current user, but I get only two result </p>
  
  <pre><code>$sql = "SELECT type FROM cars WHERE owner='".mysql_real_escape_string($_SESSION['username'])."' AND selling='0' ORDER BY id DESC "; 
  
   $result = mysql_query($sql,$con); 
  
   print_r(mysql_fetch_array($result));
  </code></pre>
  
  <p>prints out:</p>
  
  <pre><code>Array ( [0] =&gt; 18 [type] =&gt; 18 )
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$sql = "SELECT type FROM cars WHERE owner='".mysql_real_escape_string($_SESSION['username'])."' AND selling='0' "; 
  </code></pre>
  
  <p>prints out:</p>
  
  <pre><code>Array ( [0] =&gt; 16 [type] =&gt; 16 ) 
  </code></pre>
  
  <p>And the result should be something like 19, 19, 18, 17, 16 in an array. Thats all the types that has me as set as owner.  </p>
  
  <p>I have got this working now: </p>
  
  <pre><code>for ($x = 0; $x &lt; mysql_num_rows($result); $x++){
   $row = mysql_fetch_assoc($result);  
   echo $row['type']; 
  }
  </code></pre>
  
  <p>Here I print out all the values correctly, but I need to create an array with all the values. I though I could use array_push, but there most be a better way of doing it. I thought I would get all the type values with a simple mysql query. </p>