I have enough experience with PHP and PostGreSQL to get myself into trouble. And my latest project has me stumped. I've created a website database to index the articles published over 25 years in a literary journal. I followed proper database design except for one field, Subject/Keyword, where I've allowed the indexer to put in multiple lines of text. It works great to call up an article by any line of text, especially when using LIKE in the SELECT statement. However, now I want to get a list of the Subject/Keyword entries in alpha order, so that I can have people browse the Subject/Keywords and then retrieve articles based on the chosen item. I can get a list by simple SELECT, but I can't group on those entries that have more than one line, because the aren't the same as any entry that has only one line.
If I can tickle out each of the elements, I could build a second table that would give me the the list I want. Should I do this entirely in PostgreSQL, with a SELECT INTO a new table and some server-side parsing to get what I want? Or should I bring it down to a web page and then let PHP build the list? If I could do the latter, I wouldn't need to put it back into a new table.
Any suggestions? RegEx? Explode? Counting newlines?
I'm already losing sleep over this and I'm supposed to be on vacation.
Thanks for any ideas.