I have a php script that returns a resultset from mysql database like that:
nombre_musico apellidos_musico
- Rafael Ruda
- Antonio Manuel Rios
- Alejandro Astola
The source code to concat string of musicians:
while($fila = mysqli_fetch_object($result)){
$apellido = str_replace("\r","",$fila->apellidos_musico);;
$nombre = str_replace("\r","",$fila->nombre_musico);
$musicos .= $nombre . " " . $apellido .",";
}
the sql query is:
$sql = "select gr.nombre_grupo, gr.anyo_creacion, gr.descripcion, ms.nombre_musico, ms.apellidos_musico\n"
. "from musico ms, canta_para cp, grupo gr\n"
. "where ms.id_musico = cp.musico_id and gr.id_grupo = cp.grupo_id and gr.nombre_grupo = '".$name_group."'";
and the code to execute the query is:
$result = mysqli_query($mysqli, $sql);
I want to obtain result like this:
"musicos":"Rafael Ruda,Antonio Manuel Rios,Alejandro Astola"
but the result I obtain is:
"Rafael Ruda,Antonio Manuel Rios,"
What I must do to obtain te correct concatenated string. I wonder for a little help as soon as possible.