I have 3 MySQL tables:
shelf
---------------
id
project_id
label
books
---------------
id
project_id
label
booksOnShelves
---------------
id
shelf_id
book_id
project_id
user_id
I need to display what books are on what shelf in a table format, something like:
History Fiction
------- --------
book 1 book 4
book 2 book 5
book 3
So far I've got only this:
SELECT
shelf.label,
books.label
FROM booksOnShelves
LEFT JOIN shelf ON (shelf.id = booksOnShelves.shelf_id)
LEFT JOIN books ON (books.id = booksOnShelves.book_id)
WHERE booksOnShelves.project_id = ".$_POST['pid']."
AND booksOnShelves.user_id = ".$_POST['uid']."
Couple things... For some odd reason shelf label is not showing up, but if I remove all other parts in the query, like book labels, it works. Also, I can only display in one long column (via loop). How would I break it into separate coulmns, or if in one column, how do I show shelf label only once per group of books?