PHP连接表显示重复

I joined two tables successfully but I can't figure out how to condition a variable that repeats.

$kelo = "SELECT e.id, e.rosary, e.group_name, e.description, u.group_id, u.name, u.decade, u.intention, u.datume FROM `rosary_group_name` AS e INNER JOIN `rosary_groups` AS u ON e.id = u.group_id ORDER BY e.id DESC, u.group_id DESC;";

    $melo = mysqli_query($con,$kelo);
    while($row = mysqli_fetch_array($melo)){
        echo '<div style="clear:left;">' .$row['rosary']. " - ". $row['name'].'</div>';
        echo "<br />";
    } 

Display is :

JOJO - hello1
JOJO - hello2
JOJO - hello3
PAJO - hi1
PAJO - hi2
KAJO - Cheers1
KAJO - Cheers2
KAJO - Cheers3

but I need:

    JOJO - hello1
           hello2
           hello3
    PAJO - hi1
           hi2
    KAJO - Cheers1
           Cheers2
           Cheers3

how do I achieve that?

Something like this?

$melo = mysqli_query($con,$kelo);
$current = '';
while($row = mysqli_fetch_array($melo)){
    if($current != $row['rosary']) { 
        $current = $row['rosary']; 
        $display = $current . ' - '; 
    }
    else $display = '';

    echo '<div style="clear:left;"><span>' .$display . '</span><span>'.$row['name'].'</span></div>';
    echo "<br />";
} 

You can use CSS to align it or sprintf if you use a plain format.

If your primary focus is on e.rosary then this query may help you:

$kelo = "SELECT e.id, e.rosary, e.group_name, e.description, u.group_id, u.name, u.decade, u.intention, u.datume FROM `rosary_group_name` AS e INNER JOIN `rosary_groups` AS u ON e.id = u.group_id ORDER BY e.rosary ASC, e.id DESC, u.group_id DESC;";