Jump to content

display in columns without duplicating


Guest PJ

Recommended Posts

G'day, i've got a script i've done, but isn't working entirely the way it should be.

 

Currently the results display like so:

 

Room 1, Teacher 1, Student 1

Room 1, Teacher 1, Student 2

Room 1, Teacher 2, Student 3

Room 1, Teacher 2, Student 4

Room 1, Teacher 2, Student 5

Room 1, Teacher 3, Student 6

Room 2, Teacher 4, Student 7

Room 2, Teacher 5, Student 8

Room 2, Teacher 5, Student 9

 

where by I want it to show

Room 1

Teacher 1, Student 1, Student 2

Teacher 2, Student 3, Student 4, Student 5

Teacher 3, Student 6

Room 2

Teacher 4, Student 7

Teacher 5, Student 8, Student 9

 

So as you can see, column 1 field only displays the room # once, then in the next column displays the Teachers name once and displays all the students beside that.

 

And this is the current code i've got, but unsure where to go from here!

<?

$classes=mysql_query("select room, teacher, student from schooldb ORDER BY room ASC, teacher ASC, student ASC ");

 

while($row_classes=mysql_fetch_assoc($classes)) {

 

// Show records by while loop.

echo "

";

echo $row_list3[room];

echo "

";

echo $row_list3[teacher];

echo " - ";

echo $row_list3[student];

echo " ";

}

?>

I realise there is currently no table format setup, that comes later when I finish designing it, at the moment I just want to get the script working the way I prefer please.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...