Can’t save formdata in DB

You must define the checkbox to store array in order to get all the selected values. Change your input name from “data-ids” to “data-ids[]”.

<input name="data_ids[]" value="<?php echo get_the_ID(); ?>" <?= isset($results[get_the_ID()]->data_id)  == get_the_ID() ? 'checked' : '' ?> type="checkbox" />