The reply that Ilyes posted will just display each row as it is in the database, not how OP requested.
Here is one possible solution, although there may be a more efficient way to do this...
<?php
$con = mysql_connect("localhost","username","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
$result = mysql_query("SELECT engine, keyword, position FROM reports");
// Initialize the arrays (in case they are defined above)
$display = array();
$engines = array();
$keywords = array();
while($row = mysql_fetch_array($result)) {
if (!in_array($row['engine'], $engines)) {
$engines[] = $row['engine'];
}
if (!in_array($row['keyword'], $keywords)) {
$keywords[] = $row['keyword'];
}
$display[$row['engine']][$row['keyword']] = $row['position'];
}
mysql_close($con);
// Display results in a table
echo '<table>';
echo '<tr>';
echo '<th>Keyword</th>';
foreach ($engines as $engine) {
echo '<th>';
echo $engine;
echo '</th>';
}
echo '</tr>';
foreach ($keywords as $keyword) {
echo '<tr>';
echo '<td>';
echo $keyword;
echo '</td>';
foreach ($engines as $engine) {
echo '<td>';
echo $display[$engine][$keyword];
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
?>