Steve I really can't nudge you in the right direction without knowing where your trying to know where your doing it. We do not really get into code mods for
vb in product support here.
1. For instance if you want to show the totalviews on the forumhome template you need to make sure to place your plugin code to execute at that location and maybe define your query variable a unique name like $pptotalviews.
2. THE COMPLICATED PART. Your mysql query looks valid but nothing works in vb4 without defining it within the template. Look at the rest of the forumhome plugin for instance in the vb4 code I released. You will see how we define the pppro_imagebits variable into the forumhome template. That variable is not valid in vb4 until you define it.
This is why I suggested you read up on the vb4 plugin system.