Ok so on our site we have recommended reading for our users. I have the following tables:
reading_books:
id_book int(11) PK
book_title varchar(50)
book_has_link tinyint(1)
book_link varchar(100)
book_cat tinyint(1)
reading_authors:
id_author int(11) PK
author_fname varchar(30)
author_lname varchar(30)
author_qual varchar(10)
reading_rel:
book_id int(11) index // is foreign key
book_author int(11) index // is foreign key
so I came up with:
SELECT *
FROM reading_rel AS r
INNER JOIN reading_books AS b ON r.book_id = b.id_book
INNER JOIN reading_authors AS a ON r.author_id = a.id_author
However, then I dont know how to print multiple authors for one book IE
while( $kidrow = mysql_fetch_array($kids) ) {
echo "<li>";
if( $kidrow['book_has_link'] == 1) {
echo "<a href=\\"{$kidrow['books_link']}\\">";
}
echo "<u>{$kidrow['books_title']}</u>";
if( $kidrow['book_has_link'] == 1) {
echo "</a>";
}
echo "<br />
<p>{$kidrow['author_fname']} {$kidrow['author_lname']}";
if(ISSET($kidrow['author_qual']) && $kidrow['author_qual'] != "") {
echo ", {$kidrow['author_qual']}";
}
echo "</li>";
}
Prints the whole LI for each author associated with a book. I want each author to be printed in a single LI for each book. (I hope that makes sense). Any ideas would be greatly appreciated.