I have to transpose mysql value (dynamic) to colum name, as an example

```
SELECT kdsatker,
MAX(CASE WHEN kdakun=425121 THEN jumlah ELSE NULL END) AS M425121,
MAX(CASE WHEN kdakun=425122 THEN jumlah ELSE NULL END) AS M425122,
MAX(CASE WHEN kdakun=425129 THEN jumlah ELSE NULL END) AS M425129,
MAX(CASE WHEN kdakun=425131 THEN jumlah ELSE NULL END) AS M425131,
MAX(CASE WHEN kdakun=425132 THEN jumlah ELSE NULL END) AS M425132,
MAX(CASE WHEN kdakun=425134 THEN jumlah ELSE NULL END) AS M425134,
MAX(CASE WHEN kdakun=425287 THEN jumlah ELSE NULL END) AS M425287,
MAX(CASE WHEN kdakun=425513 THEN jumlah ELSE NULL END) AS M425513,
MAX(CASE WHEN kdakun=425514 THEN jumlah ELSE NULL END) AS M425514,
MAX(CASE WHEN kdakun=425515 THEN jumlah ELSE NULL END) AS M425515,
MAX(CASE WHEN kdakun=425518 THEN jumlah ELSE NULL END) AS M425518,
MAX(CASE WHEN kdakun=425519 THEN jumlah ELSE NULL END) AS M425519,
MAX(CASE WHEN kdakun=425764 THEN jumlah ELSE NULL END) AS M425764,
MAX(CASE WHEN kdakun=425791 THEN jumlah ELSE NULL END) AS M425791,
MAX(CASE WHEN kdakun=425792 THEN jumlah ELSE NULL END) AS M425792,
MAX(CASE WHEN kdakun=425793 THEN jumlah ELSE NULL END) AS M425793,
MAX(CASE WHEN kdakun=425811 THEN jumlah ELSE NULL END) AS M425811,
MAX(CASE WHEN kdakun=425911 THEN jumlah ELSE NULL END) AS M425911,
MAX(CASE WHEN kdakun=425912 THEN jumlah ELSE NULL END) AS M425912,
MAX(CASE WHEN kdakun=425913 THEN jumlah ELSE NULL END) AS M425913,
MAX(CASE WHEN kdakun=425915 THEN jumlah ELSE NULL END) AS M425915,
MAX(CASE WHEN kdakun=425999 THEN jumlah ELSE NULL END) AS M425999
FROM(SELECT kdsatker,kdakun,sum(jumlah) as jumlah FROM tb_simponi GROUP BY kdsatker,kdakun) as newdata GROUP BY kdsatker

```

the MAX CASE loop based on the value data, My last work is create array based on mysq data result

```
$sql=array();
while
($baris=mysql_fetch_array($result))
{?>
    <?
    $kodemak=$baris['kdakun'];
    $sql[]="MAX(CASE WHEN kdakun=".$kodemak." THEN jumlah ELSE NULL END) AS M" .$kodemak;
    ?>

<?}

```

The problem is how to call the $sql variable which is contain all array loop with comma delimited into one $sql variable

```
SELECT kdsatker, $sql FROM(SELECT kdsatker,kdakun,sum(jumlah) as jumlah FROM tb_simponi GROUP BY kdsatker,kdakun) as newdata GROUP BY kdsatker

```