Probably the "best" solution is to normalize the data, so that if you want to treat "Birth Defects|Pregnancy and Reproduction" as two different subjects, then they should be in the database as separate rows. You might implement that without changing the current data by (though that would reduce the amount of normalization) by breaking out all the subjects into a separate table.
Code:
topics
======
topic_id topic subject
-------- ------------------- -----------------------------------------------------
1 Abdominal Pain Digestive System Topics|Symptoms
2 Abdominal Pregnancy Female Reproductive System|Pregnancy and Reproduction
3 Abnormalities Birth Defects|Pregnancy and Reproduction
4 ABO Blood Groups Blood, Heart and Circulation
subject_to_topic
================
subject topic_id
---------------------------- --------
Digestive System Topics 1
Symptoms 1
Female Reproductive System 2
Pregnancy and Reproduction 2
Birth Defects 3
Pregnancy and Reproduction 3
Blood, Heart and Circulation 4
Then you can use a join on that subject_to_topic table to get your grouping criteria. It should be relatively simple to create either a Db query or a PHP script to populate the new relational table from the main topics table, by explode()-ing the subjects from the original topic table and inserting rows in the new table for each explode()-ed part.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks