在PHP中随机选择两行之后获取变量

I am using following code

$con=mysql_connect('localhost','admin',"password");
 $db=mysql_select_db('DbName',$con);

    $query="SELECT COUNT(shuffel.clientid) as total_users FROM shuffel";
    $result=mysql_query($query);
    $total=mysql_fetch_array($result);

    $total =$total['total_users'];

    if($total>=2)
    {
        $result=$total/2;
        $length =round($result);

        if ($length > 10)
            $length = 10;

        for($i = 0; $i < $length; $i++) 
        {
            $data = "SELECT * FROM shuffel ORDER BY RAND() LIMIT 2";
            $shuffeluser = mysql_query($data);
            int count = 0;
            while($row = mysql_fetch_assoc($shuffeluser))
            {
              $my_array[] = $row;
               count ++;
            }
                }

Now i want to get something like

$firstUserId = $my_array[0]->id;

However Everhthing just returns empty.

What is wrong in above code

mysql_fetch_assoc() returns array, not object so go get id you should use $my_array[0]['id'].

Also think about moving to PDO or mysqli_* because mysql_* is deprecated.