I would like to build a custom filter, used to do something described below, but I can't find any examples on which to base my code. I'm relatively new to php and am learning as I go, so any templates/examples that I could look at to see how this module affects views would be greatly appreciated. As for what the filter I'm trying to create should do...

My site is based around user submitted reviews of businesses. As such, I would like to display each user's individual review at the bottom of the page for the business. Users submit the reviews by creating content of type review, which contains an entity reference to the business. So, what the filter needs to do is simply only display content whose reference_field value is equal to the current nid. I've tried to build a filter based on some examples I have found here and other php I have elsewhere on my site used for a similar purpose . However, I don't know much php so any help would be greatly appreciated. Here's my current (broken, not working) code:

$my_result = db_query('
        SELECT entity_id FROM {field_revision_field_venue_reference_review}
        WHERE field_venue_reference_review_target_id = :nid');

$node = node_load($data->nid);

$nodeids = array(':nid' => $node );

while ($my_row = db_fetch_array($my_result))  

{
$nodeids[] = $my_row['nid'];
}

return $nodeids;