
Originally Posted by
Morthian
I want to make a PHP script that will get the results from a MySQL query, and then tell me how far down the list of results a particular record is?
For example:
I want to know how far down the list of results I will find the record with the ID of 440. If I manually look at the results, I find that it is the 112th record down on the list.
Whoops, I'm going to delete my original post. I misunderstood your post I think. I'll re-think it and post again.
[edit]
Ok, how about this:
Code:
$ids = array();
while($row = mysql_fetch_array($res,MYSQL_ASSOC)) {
$ids[] = $row['id'];
}
$key_index = array_search('440',$ids);
Remember that $ids is going to be zero-based, so you might want to add 1 to $key_index, depending on the usage.
Bookmarks