在html表中显示并行数据

I have very simple code:

 $resultTest = mysql_query("SELECT * FROM inventarioStat WHERE `localizacion` = 'Sagasta'  GROUP BY fecha") 
    or die(mysql_error()); 


    $rowTest = mysql_fetch_array( $resultTest );
    echo "<table border='1' padding='2' cellspacing='0' >";
     { foreach($rowTest['fecha'] as $key => $value) {



    echo "<tr>";
    echo "<td>" . $rowTest['fecha'][$key] ."</td>";
    echo "<td>" .  $rowTest['idItem'][$key] . "</td>";
    echo "<td>";
    echo $rowTest['nombreItem'][$key] ."</td></tr>";






        mysql_query($query);
    }     

}


echo "</table>";
echo "<br>";

What Im trying to get is to display all the data next to each other group by date using the html table, something like this:

Fecha                  Fecha                  Fecha
idItem nombre cantidad idItem nombre cantidad idItem nombre cantidad etc...

My code doesnt seems to be working. Can you push me in the right direction? Thank you

I think you are looking for something like this?

 $resultTest = mysql_query("SELECT * FROM inventarioStat WHERE `localizacion` = 'Sagasta'  GROUP BY fecha") 
    or die(mysql_error()); 


    echo "<table border='1' padding='2' cellspacing='0'>";
    echo "<tr>";
     {

   while ($rowTest = mysql_fetch_array( $resultTest )) {
    echo "<td>";
    echo $rowTest['fecha'];
    echo "<br />";
    echo $rowTest['idItem'];
    echo "<br />";
    echo $rowTest['nombreItem'] ."</td></tr>";
    echo "</td>";
    }     

}

echo "</tr>";
echo "</table>";
echo "<br>";

You are missing > i your code:

echo "<table border='1' padding='2' cellspacing='0' ";

Change it to:

echo "<table border='1' padding='2' cellspacing='0'>";

You are not closing the table-tag: the > is missing.

It should be echo "<table border='1' padding='2' cellspacing='0'>";

What is the point of this:

mysql_query($query);

inside the foreach loop? The variable "$query" does not appear to be declared anywhere, if you haven't declared this it could be causing a problem.

Try this:

 $resultTest = mysql_query("SELECT * FROM inventarioStat WHERE `localizacion` = 'Sagasta'  GROUP BY fecha") 
or die(mysql_error()); 


$rowTest = mysql_fetch_array( $resultTest );
echo "<table border='1' padding='2' cellspacing='0' >";
 foreach($rowTest['fecha'] as $key => $value) 
   {

echo "<tr>";
echo "<td>" . $rowTest['fecha'][$key] ."</td>";
echo "<td>" .  $rowTest['idItem'][$key] . "</td>";
echo "<td>";
echo $rowTest['nombreItem'][$key] ."</td></tr>";

}     


echo "</table>";
echo "<br>";