Android,Volley,SQL只显示一条记录?

so after much trouble shooting i have finally gotten my list view working.

Essentially my table has 3 records which should match id 1. I want these to be displayed in my android listview, only 1 is displayed. I assume my php is correct as when i enter myurl://retreiveData.php?id=1

All 3 records are displayed, how ever the android application only displays 1

I will post my php below, and the extract from the java which loops through the json data

 <?php 
 if($_SERVER['REQUEST_METHOD']=='GET'){
   $id  = $_GET['id'];
   require_once('dbConnect.php');
   $sql = "SELECT * FROM Exercises WHERE id='".$id."'";
   $r = mysqli_query($con,$sql);
   while($res = mysqli_fetch_array($r)){
   $result = array();
   array_push($result,array(
   "muscle group"=>$res['muscle group'],
   "exercise"=>$res['exercise'],
  )
  );
   echo json_encode(array("result"=>$result));
  }
   mysqli_close($con);
  }

Move the line $result = array(); above your while loop in PHP.

On every iteration you are creating a new object. On browser you are able to see because you print the value in each iteration but at the end of the while loop, it will only have the last value. You can test it by echoing the value of $result after the while loop.