title: PHP: "While" loop returns same value for each iteration of the variable
body: <p>Thanks in advance for any help offered.</p>
  
  <p>I'm performing a query that returns something like this:</p>
  
  <pre><code>route   |   busnumber
    2            300
    4            123
    2            455
   12            934
  </code></pre>
  
  <p>My goal is to print/echo a list of all "busnumber" were "route" = 2.
  I know I can do a query on the DB to do this but I don't want to run this query for each and every route.  The result set is actually part of one master, complex query so I need to accomplish my goal using the array.</p>
  
  <p>The query works correctly and does display the appropriate info.  I also return the results into an array. i.e ...</p>
  
  <pre><code>    $query=("SELECT * from foo")
      $result=mysql_fetch_assoc($query);
  </code></pre>
  
  <p>My current code looks like this (note my comments):</p>
  
  <pre><code>    mysql_data_seek( $result,0);  // because I'm previously iterating through $result
  while ($i2=mysql_fetch_assoc($result)) {
  $busnumber=$i2['busnumber']; 
  $busroute=$i2['route'];
  echo "&lt;div class='businfo'&gt;";
  if ($busroute='2'){           // I only want this to happen if $busroute=2
  echo "Current Route = $busroute&lt;/br&gt;";
  echo "Bus Number : $busnumber &lt;/br&gt;";
  }
  echo "&lt;/div&gt;";
  }
  </code></pre>
  
  <p>What I'm getting, however, it is echoing the same '$busroute' (2) but different '$busnumber' for each row as such:</p>
  
  <pre><code>Current Route = 2
  Bus Number : 194
  Current Route = 2
  Bus Number : 196
  Current Route = 2
  Bus Number : 2002
  Current Route = 2
  Bus Number : 2010
  Current Route = 2
  Bus Number : 2013
  </code></pre>
  
  <p>The problem is that all of those bus numbers are not part of route 2.  It is a listing of bus numbers from all routes.  I only want it to perform the foreach loop if $routenumber=2.</p>
  
  <p>Thanks again for the help :)</p>