Competition details

[insert_php]
function getCompetition($name)
{
echo “

$name

“;
try {
$connection = new PDO(“mysql:host=10.169.0.115; dbname=northmid_wpr2”, “northmid_wpr2”, “djos37roi3ahjoi623e”);

#Get the basic details from databse table
$sql = “SELECT type, gender, organiser, format, open, handicapped, notes FROM competitions WHERE name = ‘$name'”;
foreach ($connection->query($sql) as $row)
{
if ($row[handicapped])
{ $handicap = “handicapped “; }
else { $handicap = “”; }

$output = “Summary: A “.$handicap.$row[‘type’].” “.$row[‘format’].” competition for “.str_replace(“ALL”, “all genders”,$row[‘gender’]).”, “;

if ($row[‘open’]) { $output .= “open to all bowlers.”; }
else { $output .= “open to registered members of “.$row[“organiser”].” only.”; }

$notes = $row[‘notes’];
if(!empty($notes) && isset($notes) && !is_null($notes))
{
$output .= ” $notes”;
}
echo $output;
}

#Create Honours board
$sql = “SELECT year, player1, score1, player2, score2 FROM compresults cr left outer join competitions c on c.oidcompetition = cr.oidcompetitions where c.name = ‘$name’ and round = 1 order by year desc”;
echo “

Honours Board

“;

foreach ($connection->query($sql) as $row)
{
$output = “
“;
$output .= $row[‘year’].” Winner: “.$row[‘player1’];
if($row[‘player2’] != null)
{
$output .= “
, Runner-up: “.$row[‘player2’];
}
if($row[‘score1’] != null && $row[‘score2’] != null)
{
$output .= ” (“.$row[‘score1’].” – “.$row[‘score2’].”)”;
}
echo $output;
}

echo “

“;
$connection = null;
}
catch(PDOException $e) { echo $e; }
}

$comp=trim($_GET[“comp”]);
getCompetition($comp);
[/insert_php]