How to use recordset to get comma separated value

Hi there,

I’m using a recordsset to fill a field in a table. the only downside is that it sums up the numbers instead of show tyhe values as seperated items in the field seperated with a comma.

i use this code

/** * Selecting a field from another table using the recordset */

// Check for record
$check_sql = ‘SELECT op_id’
. ’ FROM ILP_wk_op’
. " WHERE pr_id = ‘" . {wk_id} . "’";

sc_select(rs, $check_sql);

//initialize the field
{klassen} = 0;
if (false == {rs}) // Error while accessing database
{
sc_error_message(‘Error while accessing database.’);
}
else
{
while(!$rs->EOF)
{
{klassen} += $rs->fields[0];

	$rs->MoveNext();
}
$rs->Close();

}

{wk_klassen_gekoppeld} = {klassen};

any suggestions

I don’t know if I get it

you want concat the fields instead sum them up

something like this?

$value = $value.",".$rs->fields[0];

  • is the sum operator in php

and finally
{wk_klassen_gekoppeld} =$value;

{klassen} = {klassen}.",".$rs->fields[0];

that did the trick. thanks you very much

In MySql

"SELECT GROUP_CONCAT(op_id)  FROM ILP_wk_op where pr_id ='".{wk_id}."'  group by op_id"

thanks, that’s also a good solution!