PHPBuilder Query - Request For Help
I started learning PHP and MySQL 6 weeks ago as a hobby that would some day lead to business applications. I have completed my first hobby project in its new born 1.0 version. I invite anyone here to look at it and comment.
It is a PHP/MySQL online database demo that is a list of 200+ computer-related books owned by me for use as a demonstration of the abilities of PHP and MySQL technologies. The current version is available for viewing, searching and sorting only at:
http://www.databasedrivenwebsite.com/booklist
(just click "view" rather than "login")
I am having some difficulties with some PHP code. I am hoping for the insightful and wise assistance of one of the great PHP Masters in this community like I got from "TheDefender" June 29, 2004 on my first post for help. I would greatly appreciate any assistance...from anyone.
The booklist table currently lists the information for each book (title, publisher, copyright, edition, etc.) with the exception of the authors associated with each book. The MySQL database consists of four (4) tables: "books", "publishers", "authors", and "author_lookup". The "publishers"/"books" relationship is a simple many-to-one, but the "author_lookup" table facilitates the "books"/"authors" many-to-many relationship. It is the many-to-many relationship that is giving me some trouble.
I would like my book listing to include not only a list of titles with copyright, publisher, isbn, and edition information from the "books" and "publishers" table as it now does, but I also want to include in the html table returned to the browser (via HTML embedded PHP code) a list of associated author(s) for each book listed (from the "authors" and "author_lookup" tables). It's important that I be able to list multiple authors for each line (title) listing without having to list the titles multiple times. I'm looking into "nested queries" (with which I have little experience) as a possible solution, but every time I try to create multiple select queries referencing different tables to be displayed my line listing, I break the page.
I inserted the select part of the query early in my page as follows:
mysql_select_db($pll_mysql_db, $connect);
$query_nested = "SELECT first_name, last_name FROM authors WHERE authorID=(SELECT l_authorID FROM author_lookup WHERE l_titleID=$pll_field_8)";
$nested = mysql_query($query_nested, $connect) or die(mysql_error());
I inserted the following within the html table code as follows:
while ($row_nested = @mysql_fetch_array($nested))
{
$pll_field_f = row_nested['first_name'];
$pll_field_l = row_nested['last_name'];
echo "<td>$pll_field_f $pll_field_l<br></font></td>\n";}
Any help would be greately appreciated.
Thank you in advance!
MCSPHPFAN
a.k.a. Mark