MySQL / PHP - 如何从嵌套循环内部引用和比较当前循环字段名称

I'm building a TV Guide. I want to do a single query "select * from programmes". Because, I've had it working with lots of little queries, i.e., 1 per each channel, but that's inefficient. Please can somebody help see what is wrong here? I'm getting "Fatal error: Cannot use object of type mysqli_result as array in script.php"

channels table

name
bbcone
bbctwo

programmes table

channel - time - title
bbcone - 6pm - news 
bbcone - 6.30 - weather 
bbcone - 7pm - the talk show 
bbctwo - 6pm - simpsons
bbctwo - 6.30 - futurama
bbctwo - 7pm - nature



$channels=mysqli_query($db,$getchans); 
$programmes=mysqli_query($db,$getprogs);  //holds all programmes

while ($channel = $channels->fetch_assoc())
{
css channel name divs and echo $channel['name']; //works

       while ($programme = $programmes->fetch_assoc()) 
       {
           if ($programme['channel'] == $channel['name']); 
           {    
            do programme divs
           }
       }
}

I can echo both values $programme['channel'] and $channel['name'] elsewhere and they both work, e.g., BBC1.

I can't for the life of me work out how to loop through, foreach channel, then loop through the programmes for that channel

(expected output)

bbcone - 6pm news - 6.30 weather - 7pm the talk show - 8pm etc
bbctwo - 6pm simpsons - 6.30 futurama - 7pm nature - 8pm etc 

Please can anyone tell me what I'm doing wrong?

while ($channel = $channels->fetch_assoc())
{
  // $getprogs "select * from programmes where channel_name = $channel["channel_name"]"
  $programmes=mysqli_query($db,$getprogs);
  while ($programme = $programmes->fetch_assoc()) 
   {
   }
}