Sir I want to generate a query which will convert data from rows to columns
I have this table
I want to get this result
[IMG]http://i66.tinypic.com/2hfjep4.png[/IMG]
Workers amount will go to column in relevant data
Group by code.
I wrote this query
session_start();
require_once("includes/connectw.php");
$query = "select date,code,worker,sum(amount)as amount from sales group by date,code" ;
$result = mysqli_query($con,$query)or die ("Error". mysqli_error($con)) ;
while ($row = mysqli_fetch_array ($result)){
echo($row['date'])."-";
echo($row['code'])."-";
echo($row['worker'])."-";
echo($row['amount'])."<br>";
}
The query show following result
But do not know how to display rows data into columns.
Please help