从表中分解字符串并将输出与其他表进行比较

Hello my first question here, I have a bad of trouble getting this code to work or better said how to proceed.

I have 2 tables, table 1 holds a string separated by commas, after exploding the array I want to compare the strings to another table that holds product prices related to the string.

<?php

function packages()
{
    global $db;
    $query = "SELECT * FROM product_package WHERE package_id > 1; ";
    $result = mysqli_query($db, $query) or die('<h3>Query failed</h3>');
    $rowcount = mysqli_num_rows($result);
    if ($rowcount < 1)
    {
        return;
    }
    else
    {
        while ($row = mysqli_fetch_array($result))
        {
            $singles = explode(',', $row["product_ids"]);
            $query2 = "SELECT product_price FROM products WHERE product_id = $single; ";
            $result2 = mysqli_query($db, $query2);
?>
                <tr>
                <td><?php echo $row["package_id"] ?></td>
                <td><?php echo $row["package_name"] ?></td>
                <td><?php echo $row["product_ids"] ?></td>
                <td>
                <a href="package_edit.php?product_id=<?php echo $row["package_id"] ?>">EDIT</a>
                </td>
                <td>
                    <?php
            foreach($singles as $single)
            {
                echo $single . '<br />';
            }

?>
    </td>
    </tr>
    <?php
        }
    }
}

?>

How do I echo the prices that are overlapping with $single?