I'm assuming that you are already displaying the grid and the on a tab of the edit product page.
I'm also assuming you are only looking for a way to save the posted data into your table.
If either assumption is wrong, please rephrase your question.
First, create an observer method that is triggered when a product is saved in the admin. There are many possible events that could be used, but probably catalog_product_save_after
in the adminhtml
area is a good one.
In your observer method, fetch the posted ID's from the request object:
$ids = Mage::app()->getRequest()->getParam('your_ids', array());
Then, instantiate the model (if your table data is represented by a model) or simply a resource model (if you want to only write to the table without the ORM), and pass the $ids
to the corresponding method.
Mage::getResourceModel('your_module/your_class')->saveRelatedProductIds($ids);
Since you already managed to create the grid on the tab, I'll add in a final assumption that you know about models, resource models and event observers. If not, please ask a new question about them.