from my query sql get result like this :

btsname------date------dcr
aaaa---------jan01------0.2
aaaa---------jan02------0.3
aaaa---------jan03------0.4
aaaa --------jan04------0.5
.
.
bbbb---------jan01------1.1
bbbb---------jan02------1.2
bbbb---------jan03------1.3
bbbb---------jan04------1.4
.
.

i try to change result below

btsname ----jan01-----jan02-----jan03----jan04--
aaaa--------0.2-------0.3-------0.4-------0.5
bbbb--------1.1-------1.2-------1.3-------1.4
.
.

i try to make php like this

$resulthw=mysql_query($rs);

$n = array();

while($row = mysql_fetch_assoc($resulthw)){

if(!isset($n[$row[date]])){

$n[$row] = array(0,0,0,0,0,0,0,0,0,0);

}else{

$n[$row][0] += $row[0];
$n[$row][1] += $row[1];
$n[$row][2] += $row[2];
$n[$row][3] += $row[3];
$n[$row][4] += $row[4];
};
};

foreach($n as $key=>$val){

echo "$key ....val[0]...val[1]....val[2]....val[3]......val[4]<br>";


}


but not running
could you help me??

irfani

do you really save the data in textform in the db?

=>
use explode to chunk the data and add them to a string.

$str="";
for($c=0;$c<$anz;$c++){
$tmp=explode("----",$mysqlrow);
$str[0].=$tmp[0];
$str[1].=$tmp[1];
$str[2].=$tmp[2];
...
}

echo $str[0]."<bR>";
echo $str[1]."<bR>";

should work - i haven't tested it ^^

This article has been dead for over six months. Start a new discussion instead.