Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I am trying to display a multidimensional array into html table using php nd mysql.

The array structure is like below

Array
(
    [az] => Array
        (
            [0] => Array
                (
                    [work] => dsdsds
                    [time] => 2:47---2:55
                    [total] => 8
                )

        )

    [an] => Array
        (
            [0] => Array
                (
                    [work] => sdsdsdsdsd
                    [time] => 1:47---2:47
                    [total] => 60
                )

        )

    [mu] => Array
        (
            [0] => Array
                (
                    [work] => sdsdsd
                    [time] => 1:30---2:48
                    [total] => 78
                )

        )

    [raj] => Array
        (
            [0] => Array
                (
                    [work] => dsdwew
                    [time] => 3:34---3:40
                    [total] => 6
                )

            [1] => Array
                (
                    [work] => cdsfdfdfd
                    [time] => 3:25---3:35
                    [total] => 10
                )

        )

)

it will go through columns first and then it will come to rows like this

user1   user2   user3
aa      bb      cc

Plz suggest..

share|improve this question
    
You should supply an example of the data, and what the output would look like using that data. Right now your data and example don't match. – goat Feb 3 '10 at 16:36

2 Answers 2

U should read about foreach.

http://php.net/manual/en/control-structures.foreach.php

And I think that inserting this values into table won't be any problem.

share|improve this answer

If i understand your question write that's what y need

    foreach($array as $tr=>$trData)
    {
      echo "<tr>{$trData["which field you want to display"]}</tr>";

      echo "<tr>";
      foreach($tdData as $td=>$tdData)
      {
         echo "<td>{$tdData["which field you want to display"]}</td>";
      }
    echo "</tr>";
    }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.