I have a simple query that i'm using MYSQL'S GROUP_CONCAT() function:
SELECT `ProductID` , GROUP_CONCAT( Description
SEPARATOR "\n" ) AS description
FROM Features
GROUP BY `ProductID`
The above query works fine on the phpmyadmin interface i.e. the values are returned displayed in a new line as shown below:
However, when i run the query in the browser, the values are separated by a space and not in a new line as i would wish:
i should mention i have even tried using the br tags as the separator (GROUP_CONCAT( Features.Description SEPARATOR "<br>" ))
but still doesn't display the values in a new line.
Any help will be highly appreciated
This would be something you want to do in PHP not MySQL. This will allow for it to display properly for both html (browser) and non html renderers (cli). The reason this works in phpMyAdmin is because it uses nl2br to convert new lines (
\n
) to html breaks (<br>
).Example:
Your code may be different this is just assuming $row is a single row from the results.