Making multidimensional array with php and mysql and display

Hi All,

I am making a daily activity report using php and mysql.Now while doing this I am facing some problems.Let me explain you.The below is the code where I am building a two dimensional array.

$sql=mysql_query("select * from report,admin_table where report.admin_id=admin_table.admin_id and which_day='2010-2-2' ") or die(mysql_error());    
             
while($row=mysql_fetch_array($sql))
{
$admin_name=$row['admin_name'];
$activity=$row['activity'];  
$test_array[] = array($admin_name,$activity,);
}

Now if I print this test array it gives as

Array
(
    [0] => Array
        (
            [0] => aziz
            [1] => dsdsds
        )

    [1] => Array
        (
            [0] => anis
            [1] => sdsdsdsdsd
        )

    [2] => Array
        (
            [0] => mujeeb
            [1] => sdsdsd
        )

    [3] => Array
        (
            [0] => raj
            [1] => dsdwew
        )

    [4] => Array
        (
            [0] => raj
            [1] => cdsfdfdfd
        )

)

while printing it as html table it displays as


<table border="1"><tr><th>aziz</th><th>anis</th><th>mujeeb</th><th>raj</th><th>raj</th></tr><tr><td>dsdsds</td><td>sdsdsdsdsd</td><td>sdsdsd</td><td>dsdwew</td><td>cdsfdfdfd</td></tr></table>

which is not a desired output.I like to display it as

<table border="1"><tr><th>aziz</th><th>anis</th><th>mujeeb</th><th>raj</th></tr><tr><td>dsdsds</td><td>sdsdsdsdsd</td><td>sdsdsd</td><td>dsdwew</td>
</tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>cdsfdfdfd</td>
  </tr>
</table>

Am i doing wrong in building up the array or doing wrong in displaying html.I guess its wrong in building up the array…I can’t understand…Please suggest.

Thanks,
Raj

Show us the code which is producing the HTML and then we can try to help you.

Just add the
and \ in your printing code…

Here is the code which is producing html table

$Rockbands1= array();
foreach ($test_array as $i => $Rockband){
   foreach ($Rockband as $j => $value)   $Rockbands1[$j][$i]= $value;
}
echo '<table border="1">';
foreach($Rockbands1 as $key => $Rockband)
{
 $tag = ($key === 0) ? 'th' : 'td';
 echo '<tr>';
 foreach($Rockband as $item)
 {
  echo "<$tag>$item</$tag>\
\	";
 }
 echo '</tr>';
}

I was thinking if the array can be something like this

Array
(
    [0] => Array
        (
            [0] => aziz
            [1] => dsdsds
        )

    [1] => Array
        (
            [0] => anis
            [1] => sdsdsdsdsd
        )

    [2] => Array
        (
            [0] => mujeeb
            [1] => sdsdsd
        )

    [3] => Array
        (
            [0] => raj
            [1] => dsdwew
            [2] => cdsfdfdfd
        )
     
)

I have attached a screenshot of how I want the table to look like…where monday tuesday…will be user1…user2…user3 and below the cells will be filledup by the activities within different specific period of time