This should be relatively easy for you.
Here's what we want to do.
Someone goes to my profile, or someone else's profile.
Just as the profile loads, the profile checks to see if the owner of the profile that is being displayed is a paying member. If the profile does belong to a paying member, then that means we need to log who viewed the profile. Otherwise we won't waste any more resources on the non paying profile. :)
To log who viewed a paying members profile, we'll check to see if the viewer is logged in, if the viewer is logged in, we'll add their user_id/name to the log for that paying member, but not before checking to see if there is
already more than 99 in the persons log, we'll have to take off the last one before adding the new one. Basically the newest should be at the top and the oldest at the bottom.
If the viewer is not logged in, then Guest will be displayed for that visitor in the log.
Again logging only happens on profiles of paying members. :)
FYI: It is easy to determine a logged in member if the member_id session exists, and it's easy to see if someone is paying because they will have paying = 1 which is right in the members table. :)