I need to populate a simple URL redirect with data from a MySQL d-base query. The data is the names of organizations. The query will return up to three records, and some of the organization names will include a comma, eg., "Community Development Coalition, Inc." Therefore I need to use a delimiter other than a comma to separate each piece of data in the URL string. What I am going for would look like this (using a pipe delimiter):
http://www.website.com?org=Name+of+org+1|Name+of+org+2|Name+of+org+3
The problems I'm experiencing are:
(1) Using either urlencode or rawurlencode, a comma in the original organization name data gets turned into %2c. This screws up the next call to the database since org names in the d-base include commas, not "%2C". How can I get the comma to appear as a comma in the URL?
(2) After querying the d-base pre-URL redirect, I get the query results and then add the pipe delimiter like so in prep to create the URL redirect:
$org_name = $org_name . "|";
This is a problem because the pipe is then added to the end of the URL string and so the resulting d-base query thinks there is one more org name to search for. Is there any way that I can chop off this last pipe? Or a better way to set this whole thing up.
Any help much appreciated!