Display data from database with PHP

Hi i am a little bit stuck.

I have two atbels, i retrieved the data from them but i don’t know how to group the data.

The output i want:

Session 1
-ex name
-ex name

The output i get:

Session 1
-ex name

Session1
-ex name

I think i need to put the data in an associativ array but i don’t know how.

If you can, please help me!
Thank yoouuuu.

My code:

<?php
$query = "SELECT * FROM programs_sessions INNER JOIN exercises ON programs_sessions.session_id = exercises.session_fk  WHERE prog_fk=". $prog_id;
$result = mysqli_query($conn, $query );

$sessions = array();

if (mysqli_num_rows($result) > 0 ) {
   while ($row = mysqli_fetch_assoc($result)) {
     $sessions[] = $row;
    }
}
 

Try to do a plain query using https://www.db-fiddle.com/f/f8nZn5LQfbmKxAdxX2fdej/0 Then it is easier to help you.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.