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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.