Trying to group students based on these which groups they are in. I'm trying to dispaly the result in some sort of object/JSON so that I could apply some sorting algorithims in JS later. Not sure how to add the WHERE statement or Join statement?
$link = mysqli_init();
$success = mysqli_real_connect( $link, $host, $user, $password, $db, $port);
$query = mysqli_query($link, "SELECT s_id, group_id, name FROM Group, Student");
    $table = array(); 
    while($row = mysqli_fetch_assoc($query)) 
    { 
    $table = $row;
     echo json_encode($table);
     }
I want result something like 
`
[{'Group': 1, 'name': 'john', 'ID': 101},
{'Group': 1, 'name': 'mike', 'ID': 103},
{'Group': 2, 'name': 'alice', 'ID': 102}, 
{'Group': 2, 'name': 'rachel', 'ID': 104},]`
the "Student" table
    s_id     class_id   name
    101         1         john
    103         1         mike
    102         1         alice
    104         1         rachel
the "Group" table
    class_id   s_id    group_id
    1          101         1
    1          102         2
    1          103         1
    1          104         2
 
     
    