Looking at ebay for inspiration, it looks like they do it with anchors.
Each row's generated href has the item in the querystring, but also a hash parameter. An anchor with the same hash name is also in there - just before the row.
So when clicked the user is taken to the item details page and the anchor name is taken across too.
Then on the details page, the link back has the hash appended to go back to the anchor in results.php
So my generated link on search.php needs to be
<a name="173"><a href="/detail.php?ID=173">Title for 173 here</a>
And the link generated on detail.php needs to be (parameters retrieved from session)
<a href="/results.php?keyword=hello#173">Back to Search results</a>
I think this might actually work!