$stmt = $db->prepare("(SELECT '1' as type, '1' as speaker_id, id, `name`, `company`, `photo`, `pos` FROM `forum_speaker` WHERE `year`=:year AND section=:section ORDER BY `pos` ASC) UNION (SELECT '2' as type,esb.speaker_id, esb.id, sb.`name`, sb.`company`, sb.`photo`, esb.`pos` FROM `forum_speaker_base` AS esb, `speakers_base` AS sb WHERE esb.`year`=:year AND esb.`speaker_id`=sb.`id` AND esb.section=:section ORDER BY esb.`pos` ASC) ORDER BY `pos` ASC");
$stmt->bindParam(':year',$year, PDO::PARAM_STR);
$stmt->bindParam(':section',$section, PDO::PARAM_STR);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $speaker)
{
echo "
".$speaker['name']."".$speaker['company']."
";
}
?>