Edward Guereque
asked on
Split comma separated values from a table column into rows using php PHP
Would anyone have an idea or point me in a direction on how I would be able to split a comma separated field into it's own rows on another table? I'm currently using php and mysql. Greatly appreciated. Thanks.
Eddie
Eddie
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh yes, I'm thinking I need select from the database, iterated through the rows and explode (explode function) the rows that have comma delimited values then insert into it's own table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Julian: I think you're on the right track, but there probably needs to be a many-to-many relationship between submissions and reasons, implying some kind of a junction table or similar structure.
@Edward: Please don't keep us guessing. A description of your data is never as good as seeing the actual data. It's like showing a hungry man a picture of a sandwich! Please post the test data. Thanks.
If you're new to PHP and want to learn the language, this article can help you get a good footing.
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
@Edward: Please don't keep us guessing. A description of your data is never as good as seeing the actual data. It's like showing a hungry man a picture of a sandwich! Please post the test data. Thanks.
If you're new to PHP and want to learn the language, this article can help you get a good footing.
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
ASKER
@Ray: Thank you for sharing your Post test data link and the PHP articles as well. I will be posting test data shortly. I'm new to Experts Exchange and I was wondering how people are sharing test data. Or I can attach a csv file a well. Thanks.
@Julian: Thank you for your input. I'm taking a look.
@Julian: Thank you for your input. I'm taking a look.
@Julian: I think you're on the right track, but there probably needs to be a many-to-many relationship between submissions and reasons, implying some kind of a junction table or similar structure.If we are maintaining reasons as an entity on its own - but that would imply some sort of structured selection of reasons. If people are freeforming it then the link to reasons does not need to go through a linking table.
ASKER
Oh, the database is MySQL and code I'm using is PHP. Thanks.