Taking multidimentional data in a array using mysql query

        $result = mysql_query("SELECT atten_hour, atten_date, mba_manpower_master.designation FROM ".TBL_MAIN." LEFT JOIN mba_manpower_master on mba_attendance.eid = mba_manpower_master.mid ");
        if (!$result) {
            die("Query to show fields from table failed");
        }
        $fields_num = mysql_num_fields($result);
        echo "<h1>Table: {$table}</h1>";
        echo "<table border='1' cellspacing='0' cellpadding='3'><tr>";
        // printing table headers
        for($i = 0; $i < $fields_num; $i++) {
            $field = mysql_fetch_field($result);
            echo "<td>{$field->name}</td>";
        }
        echo "</tr>n";
        // printing table rows
        while ($row = mysql_fetch_row($result)) {
            echo "<tr>";
			
			 $hour_master_raw[] = array($row);
			
            // $row is array... foreach( .. ) puts every element
            // of $row to $cell variable
            foreach($row as $cell)
            if($cell) echo "<td>$cell</td>";			
            else echo "<td>&nbsp;</td>";
            echo "</tr>n";
        }
        mysql_free_result($result);
		
		
	//	var_dump( $hour_master_raw);
	
	$designation = array(
			"Fitter",
			"Grinder man",
			"Khalasi",
			"Rigger",
			"Supervisor",
			"Welder"
			);
	
	foreach ( $designation as $d ){		
				
	foreach($hour_master_raw as $entry)
	{			
			foreach($entry as $x)
			{		
				//	$x[2] // Desig
				//	$x[1] // Date
				//	$x[0] // hour		
				if($x[2] == $d)
				{
					if(array_key_exists($x[1],$hour_master)){
					
						$past_hour = $hour_master[$x[1]];
					
						$hour_master[$x[1]] = $x[0] + $past_hour;
					
					} else {
						$hour_master[$x[1]] = $x[0];
					}
				}	
			}
	}	
	$att_data_master[$d] = $hour_master;
	}
	
	var_dump($att_data_master);
	unset($att_data_master);