i have array name grievance_pending it has values like "a","b","c","d" are particular section and x,y,z,w are grievance solving level i want to show the status of grievances how many are pending at x , y, z and w for all the sections example: array values like a-x,a-y,a-z,a-w, b-x,c-x,c-y,d-w,e-x,e-y,e-w in the same way "a" may have 4 values or 3 values or 2 values or 1 values i want display as below
x y z w total
a 0 1 2 0 3
b 0 0 0 1 1
c 0 5 0 1 6
pls suggest any method to transpose array
while($row_count = mysql_fetch_array($qry_count,MYSQL_ASSOC)) {
if($x=="")
{
if ($j>0)
{
$j++;
}
$x=$row_count['unitname'];
$unit_name[$j][0]=$x;
$unit_name[$j][1]=0;
$unit_name[$j][2]=0;
$unit_name[$j][3]=0;
$unit_name[$j][4]=0;
raised_level($raised_level);
}
else
{
$row_count['unitname'];
if($x!=$row_count['unitname'])
{
$j++;
$unit_name[$j][0]=$row_count['unitname'];
$unit_name[$j][1]=0;
$unit_name[$j][2]=0;
$unit_name[$j][3]=0;
$unit_name[$j][4]=0;
raised_level($raised_level);
$x="";
}
else
{
raised_level($raised_level);
}
}
}
// funtion raised Level function raised_level($raised_level) {
switch($raised_level)
{
case "FHQrsBranch":
$fhq_count=$fhq_count+$row_count['total_grievances'];
$unit_name[$j][1]=$fhq_count;
$fhq_count=0;
break;
case "Sector":
$sector_count=$sector_count+$row_count['total_grievances'];
$unit_name[$j][2]=$sector_count;
$sector_count=0;
break;
case "Zone":
$zone_count=$zone_count+$row_count['total_grievances'];
$unit_name[$j][3]=$zone_count;
$zone_count=0;
break;
case "Unit":
$unit_count=$unit_count+$row_count['total_grievances'];
$unit_name[$j][4]=$unit_count;
$unit_count=0;
break;
}
}