I am trying to print the different category\'s selected in a single line in xml, like
meeting, food and drinks, sports
Or use a rtrim, rtrim( $cat , ',' )
http://php.net/rtrim
You can do this by [i used my variable]
$str = substr($str,0, (strlen($str)-1));
Call trim() with the optional second parameter as a ','
trim($cat_name, ',')
However, since you're doing this in a while loop, you should build an array then implode()
it rather than building the string in the loop. This avoids the extra comma to begin with.
$arr = array();
while($row=mysql_fetch_array($e))
{
$arr[] = $row['cat_name'];
}
$cat_name = implode(",", $arr);
// $cat_name is now "meeting, food and drinks, sports"