How to change the amount & mobileid from the array of $result & $winnum by using the foreach()

<?php
include("include/connection.php");

function getwindata($con) {    
    $query = "SELECT userid,amount FROM tbl_walletsummery WHERE actiontype='win'";
    $results = mysqli_query($con, $query);
    if( $results === false ) {
        throw new Exception('Query failed: ' . $con->error);
    }
    $msg = '';
    $msg1 = '';
    $mobileid = '';
    foreach($results as $result) {
        $query1 = "SELECT id,mobile FROM tbl_user WHERE id={$result['userid']}";
        $getuser = mysqli_query($con, $query1);
        $msg1 .= " Wins {$result['amount']}</span1>";
        $mobileid = '';
        foreach($getuser as $winnum) {
        $mobileid .= substr_replace($winnum['mobile'], "******", 2, 6);
        $msg .= "<span1>Congratulations To $mobileid $msg1";
        }

    }
return $msg;
}
$mob = getwindata($con);
?>

I want to get the matched data as 9999999999 mobile number wins 1k and his user id 1 then tbl_walletsummery table has the winning amount and userid only and tbl_user has mobile and mail and idf the user so i want to match them to get the proper winner number & winning amount to be print in span tag