SELECT `Topic 1`,`Topic 2` FROM (SELECT (case when col1='Topic 1' then col2 end) AS `Topic 1` , (case when col1='Topic 2' then col2 end) AS `Topic 2` FROM stepien) AS x1;
<?php
$dsn = 'mysql:dbname=forumphp;host=localhost';
$user = 'root';
$password = 'mystrongpass';
$dbh = new PDO($dsn,$user,$password);
$query = "select `Topic 1`,`Topic 2` from (select (case when col1='Topic 1' then col2 end) as `Topic 1` , (case when col1='Topic 2' then col2 end) as `Topic 2` from stepien) as x1;";
$tmp = $dbh->query($query);
while($result[] = $tmp->fetch()){}
$a1=0;
$a2=0;
for($i=0;$i<count($result);$i++) {
if($result[$i]['Topic 1']!==NULL) {
$a1++;
}
if($a1==1) {
}
if($result[$i]['Topic 2']!==NULL) {
$a2++;
}
if($a2==1) {
}
echo $result[$i]['Topic 1']; echo $result[$i]['Topic 2'];
}
?>