I am attempting to change portions of a string record set returned by a mysql_fetch_array function within a nested while loop. The results are pulled from MySQL tables with one to many relationships, so I sometimes get more than one string result per iteration through the while loop. The results returned are correct, but I am wondering how I can change the returned strings so that there are spaces and commas between the strings? For example, the category results returned for product may be "Television" and "Movies", but it is returned as "TelevisionMovies". Mulitple string results are returned as separate arrays, preventing me from manipulating the results as one string. I've really been struggling with this and would appreciate any help.
Here are some excerpts from my code:
<?php
. . .
while(($myrow = mysql_fetch_array($result1)) && $i <=4) {
. . .
echo "<span style=\"color:#F00\">";
$query4 = "SELECT category.category_id,category.category
FROM category
JOIN product_list_to_category
ON category.category_id = product_list_to_category.category_id
JOIN product_list
on product_list_to_category.product_id = product_list.product_id
WHERE product_list.product_id =".$product_id;
$result2 = mysql_query($query2,$database);
while ($myrow2 = mysql_fetch_array($result2)) {
echo $myrow2['category']; /*This is the problem line. How do I format multiple categories returned for one row?*/
}
echo "</span>";
}
. . .
?>