0

OK! This will probably reveal my IQ , but here goes.

I am new to PHP and MySQL--I am learning from a ton of books--and I am struggling with many-to-many relationships. All of the books make a lot of assumptions. I get the concept just not the mechanics.

Say I have a people table and an address table. The people can have many addresses and the addresses can be applied to many people (roommates, etc.). Now I know to create a people table with say "peopleID" and then "FirstName" and "LastName". Then I make address table with "addID", "Street", "City", "State" and "Zip". OK, now I need a many-to-many table, say "peopleadd" with fields "peopleID" and "addID". OK so good, but not one of these books or tutorial sites tells how to populate/insert into these tables. I know how to retrieve, I think, but not how to insert.

One site I went to said that one should not insert into multiple tables, as it is bad form.

So how to I take say a form that asks for name and address and insert that data into the tables?

Thanks,

K. Chris C.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jrw89
0

OK! This will probably reveal my IQ , but here goes.

I am new to PHP and MySQL--I am learning from a ton of books--and I am struggling with many-to-many relationships. All of the books make a lot of assumptions. I get the concept just not the mechanics.

Say I have a people table and an address table. The people can have many addresses and the addresses can be applied to many people (roommates, etc.). Now I know to create a people table with say "peopleID" and then "FirstName" and "LastName". Then I make address table with "addID", "Street", "City", "State" and "Zip". OK, now I need a many-to-many table, say "peopleadd" with fields "peopleID" and "addID". OK so good, but not one of these books or tutorial sites tells how to populate/insert into these tables. I know how to retrieve, I think, but not how to insert.

One site I went to said that one should not insert into multiple tables, as it is bad form.

So how to I take say a form that asks for name and address and insert that data into the tables?

Thanks,

K. Chris C.

Try the MySQL sections on the w3schools and tizag websites to get the basics (including INSERT), followed by the PHP and MySQL online manuals.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.