I think this was recently asked but I was a little lost on the example that was used so I'm reasking it with an example I can understand.
Also forgive me for such a basic question but I really am new to Mysql and PHP.
In the book "Build Your Own Database Driven Website Using PHP & Mysql" by Kevin Yank, they give an example for when using a many to many relationship that it is best to use a lookup table. The example they show of how it works is fine, I understand it however they have you manually enter the needed data into the fields. I'm sure later in the more advance sections they will show me how to do this but I don't see it jumping out at me when I've looked for it.
What I'm wanting to learn is how to have the data entered automatically from one tables field, in this case ID entered into the lookup table. Clearer in example below of what I'm looking for.
Example that was given in the book:
Table = joke
Fields = id and joketext
Primary key = id and it is auto incremented
Table = category
Fields = id and category
Primary key = id and it is auto incremented
Table = jokecategory and is the lookup table
Fields = jokeid and categoryid
Both are Primary Keys.
So what I want to have happen is when a new record is entered in joke table it's id value is entered into the jokeid field of the jokecategory table and then when a category is selected for this joke it's id value is entered into the categoryid field of the jokecategory table.
How does one do this?