title: Assign PHP variable to each row
body: <p>The following mysql query is getting the last 4 records from the 'residential' table but I'm trying to assign a php variable ($postcode) to each row (the 3rd [3] column in particular) for use in on another page. The following doesn't seem to be split the rows out correctly to assign to each variable?</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("example.com","peter","abc123","my_db");
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  
  $result = mysqli_query($con,"SELECT * FROM residential ORDER BY My_id DESC LIMIT 4");
  
  $postcodes = array();
  
  while ($row = mysqli_fetch_array($result))  
  {
  $postcodes[] = $row[3];
  }
  
  echo "location one " . $postcodes[0];
  echo "&lt;br&gt;";
  echo "location two " . $postcodes[1];
  echo "&lt;br&gt;";
  echo "location three " . $postcodes[2];
  
  mysqli_close($con);
  ?&gt;
  </code></pre>