Each row in the table has an image location, an id, and what group it belongs to. I am using the above line to determine what position the image is in, within the possible result set. So image 5 of 10, where 5 was from this query. The actual query has an addition like:
WHERE id < $current_id AND group_id= $group_id