Forums

PHP

This topic is locked

creating a one-to-many relationship

Posted 25 May 2006 09:02:13
1
has voted
25 May 2006 09:02:13 Andrew A-P posted:
I am having problems creating a one-to-many relationship using php and dreamweaver. I currently use SQLYog for my database and easyPHP 1.8 for the servers and Dreamweaver MX 2004 for the Web editing. I have a database of books which I have placed into a php website. It's actually really cool! It functions much like amazon.com's book database. the part I am missing is authors. In amazon, when you look up a book, it has more that has more than one author, all of the authors names show up. I can only get one to show or get that same book to show several times (as many as there are authors). One book can be written by many authors. I have set up the database in MS Access and have all the tables normalized and the database functions properly. so I exported the database into SQLYog and am using this instead of access. When I set up my database, I can not put in any authors (not because I don't have the knowledge) because I can not set the relationship with the correct tables. Is there a php trick to get this to work or is there a better (free) alternative to SQLYog that can correct this problem.
Here are the tables

Book (Table)
---------------
BookNum
Title
Subtitle
Edition
Publisher
Pages
...

Author (Table)
---------------
AuthorNum
AuthorFirst
AuthorLast
AuthorMI

Wrote (Table)
----------------
BookNum
AuthorNum

There are other tables but they are not important to this question

In Access the relationship is:

Book Wrote Author
------ ------- --------
BookNum -1---M- BookNum AuthorFirst
Title AuthorNum -M---1- AuthorNum

Now if I add a book to the Dreamweaver site, I can not add more than one author to a book because the one book repeats itself by however many authors I have for that book. I know for a fact this is either the fact that one to many (1-M) relationships dont exist in SQLYog or there is a php code I am missing.

Please do not hesitate to ask me for any code, more of the database, SQL recordsets in dreamweaver, etc. I am abliged to help you if you help me or at least point me in the correct direction.

Replies

Replied 25 May 2006 11:45:32
25 May 2006 11:45:32 Roddy Dairion replied:
What am gona ask you is your database design. And also if possible a link to the page where the code is executing.
Replied 26 May 2006 00:11:59
26 May 2006 00:11:59 Andrew A-P replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
What am gona ask you is your database design. And also if possible a link to the page where the code is executing.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

I unfortunately do not have this site up and running online but I am posting an image of the relationship of the tables in access which shows everything you should need. If you can think of another piece you need I am willing to help. BTW is there a free site I can upload my database and files temporarily to show you?

<img src="C:\Documents and Settings\Andrew\My Documents\My Pictures\relationship.JPG" border=0>
Replied 26 May 2006 05:36:10
26 May 2006 05:36:10 Andrew A-P replied:
O.K. so I took the afternoon to set up an online version of the site. You will notice that there is no authors. I need this fixed. See explaination in my first reply

alsoszaa.awardspace.com/bookdb/catalog.php

you need to use the following credentials:
username: test
password: password

The site is not complete so please don't mind the buttons that don't work.
Replied 26 May 2006 05:46:17
26 May 2006 05:46:17 Andrew A-P replied:
OOPS I almost forgot,

when you click on the book title it takes you to a detailed page. On this page is where I want the authors to appear. my database file is called "alsoszaa_books"

If possible, would you know how to change checkmarks in a database to yes/no because the CD Included part shows up as 1 or 0

Reply to this topic