I am trying to convert my not so well structured mysql article data to a better many-to-many structure.
basically I have on article table with fields ‘article_id, title, author_1, author_2, author_3, … , author_10’ where article id is unique and the author fields hold full names.
What I need is a manay-to-many relationship where I end up with an article table of ‘article_id, title’ an intermediate table which holds ‘article_id, author_id’ and an author table which holds ‘author_id, author_name’.
I know there must be a way to do this with a few lines of code. I have tried all day with puling the data out and trying to match arrays in php but getting nowhere.
Any help would be much appreciated.
It’s pretty straightforward:
mysql_insert_id()to get the ID of the inserted row, and insert the relationship into the article/author table.–