title: PHP & MYSQL - GET POSITION OF ROW
body: <p>Can you return the position of the row in comparison to the previous search. For example if I did a simple query: <code>select * from table where name='aa'</code></p>
  
  <p>it would return</p>
  
  <pre><code>+--+----+---+
  |id|name|cid|
  +--+----+---+
  | 1|  aa|  2|
  | 5|  aa|  2|
  | 8|  aa|  2|
  | 9|  aa|  2|
  |10|  aa|  2|
  +--+----+---+
  </code></pre>
  
  <p>If I changed that query to:
  <code>select * from table where name='aa' and id='5'</code></p>
  
  <p>it would return</p>
  
  <pre><code>+--+----+---+
  |id|name|cid|
  +--+----+---+
  | 5|  aa|  2|
  +--+----+---+
  </code></pre>
  
  <p>now according to the first search for <code>where name='aa'</code> there are 5 rows with <code>and id='5'</code> being the second row.</p>
  
  <p>So, is there a way to get the position of the row in comparison to initial set? I'd like to be able to print "Result 2 of 5". I can get the number <code>5</code> by counting the total rows. I just need to get the position of the <code>and id='5'</code>. Which I know is the second row of the initial set but I can't seem to figure out a way to return that information. Forgive me if I'm not explaining this properly as I don't quite know how to ask this question.</p>