Player Details

‚Äč

[insert_php]
$player = $_GET[“searchtext”];
if(!(!isset($player ) || trim($player )===”))
{
try
{
$dbh = new PDO(getConnString(), getUser(), getpw());
$dbh2 = new PDO(getConnString(), getUser(), getpw());

#$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

$sql = “SELECT homeplayer as \”Player\”, count(*) as \”Played\”, sum(CASE WHEN played = \”Home\” THEN 1 ELSE 0 END) as \”HP\”, sum(CASE WHEN played = \”Home\” and homescore = 21 THEN 1 ELSE 0 END) as \”HW\”, sum(CASE WHEN played = \”Away\” THEN 1 ELSE 0 END) as \”AP\”, sum(CASE WHEN played = \”Away\” and homescore = 21 THEN 1 ELSE 0 END) as \”AW\”, sum(CASE WHEN played = \”Home\” THEN (homescore – COALESCE(awayscore, 11)) ELSE 0 END) as \”HSD\”, sum(CASE WHEN played = \”Away\” THEN (homescore – COALESCE(awayscore, 15)) ELSE 0 END) as \”ASD\”, max(cmg.matchdate) as \”LastPlayed\”, min(cmg.matchdate) as \”FirstPlayed\” FROM countymatchesgames cmg left outer join countymatches cm on cm.oidcountymatches = cmg.oidcountymatches where lower(homeplayer) like lower(‘%$player%’) group by homeplayer order by homeplayer”;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
$count = 0;
foreach ($dbh->query($sql) as $row)
{
$count++;
$player = $row[‘Player’];
$gamesPlayed =$row[‘HP’] + $row[‘AP’];
echo “

“;
echo “

“;
echo “

“;
echo “

“;
if($gamesPlayed > 0)
{
echo “

“;
echo “

“;
}
else
{
echo “

“;
}

echo “

“;
echo “

“;
$homePlayed =$row[‘HP’];
if($homePlayed > 0)
{
echo “

“;
echo “

“;
}
else
{
echo “

“;
}
echo “

“;
echo “

“;
$awayPlayed =$row[‘AP’];
if($awayPlayed > 0)
{
echo “

“;
echo “

“;
}
else
{
echo “

“;
}
echo “

“;

$greenSQL = “SELECT green, count(*) as tot FROM countymatchesgames cmg left outer join countymatches cm on cm.oidcountymatches = cmg.oidcountymatches where lower(homeplayer) = lower(‘$player’) group by green order by count(*) desc limit 1”;
foreach ($dbh2->query($greenSQL) as $row2)
{
if($row2[‘tot’] > 1) { echo “

“;

if($row2[‘tot’] > 1)
{
echo “

“;
}
}

echo “

“;
}
echo “

PlayerPW%AggHPHWH%HAggAPAWA%AAgg
$player$gamesPlayed“.($row[‘HW’] + $row[‘AW’]).”“.number_format((($row[‘HW’] + $row[‘AW’]) / $gamesPlayed) * 100, 1) .”“.number_format(($row[‘HSD’] + $row[‘ASD’]) / ($row[‘HP’] + $row[‘AP’]), 2) .”NANA“.$row[‘HP’] .”“.$row[‘HW’] .”“.number_format(($row[‘HW’] / $homePlayed) * 100, 1) .”“.number_format($row[‘HSD’] / $homePlayed, 2) .”NANA“.$row[‘AP’] .”“.$row[‘AW’] .”“.number_format(($row[‘AW’] / $awayPlayed ) * 100, 1) .”“.number_format($row[‘ASD’] / $awayPlayed , 2) .”NANA
“;}
else { echo “

“;}
echo “Played from “.date(“d/m/Y”, strtotime($row[‘FirstPlayed’]));
echo ” to “.date(“d/m/Y”, strtotime($row[‘LastPlayed’])).””;
echo “
Most played green – “.$row2[‘green’].” (“.$row2[‘tot’].”)


“;

$sql = “SELECT homeplayer as \”Player\”, cm.matchdate as \”Date\”, played as \”Played\”, green as \”Green\”, homescore as \”For\”, awayscore as \”Against\”, awayplayer as \”Opponent\”, cm.issupplemental FROM countymatchesgames cmg left outer join countymatches cm on cm.oidcountymatches = cmg.oidcountymatches where lower(homeplayer) like lower(‘%$player%’) order by cmg.matchdate”;
echo “

“;
if($count > 1) { echo “

“; }
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
foreach ($dbh->query($sql) as $row)
{
$date = date(“jS M Y”, strtotime($row[‘Date’]));
echo “

“;
if($count > 1) { echo “

“; }
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
}
echo “

PlayerDatePGreenFAOpponent
“.$row[‘Player’].”“.$date;
if($row[‘issupplemental’] == true) { echo ” *”; }
echo “
“.strtoupper(substr($row[‘Played’],0,1)).”“.$row[‘Green’].”“.$row[‘For’].”“.$row[‘Against’].”“.$row[‘Opponent’].”

“;
echo “

* Supplemental match

“;
$dbh= null;
}
catch(PDOException $e) { echo $e; }
}
[/insert_php]

[insert_php]
$player = $_GET[“searchtext”];
if(!(!isset($player ) || trim($player )===”))
{
try
{
$dbh = new PDO(getConnString(), getUser(), getpw());
$sql = “SELECT c.name as comp, (lower(player1) like lower(‘$player%’)) as isp1, year, player1, score1, player2, score2 FROM compresults cr left outer join competitions c on c.oidcompetition = cr.oidcompetitions where round = 1 and lower(player1) like lower(‘$player%’) or lower(player2) like lower(‘$player%’) order by year desc, c.name desc”;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
echo “

“;
foreach ($dbh->query($sql) as $row)
{
$isP1 = $row[‘isp1’];
$s1 = $row[‘score1’];
$s2 = $row[‘score2’];

if(($isP1 == 1 && $s1 == 21) || ($isP1 == 0 && $s2 == 21) || ($s1 == $s2 && $isP1))
$result = “Winner”;
else
$result = “Runner up”;

echo “

“;
echo “

“;
echo “

“;
echo “

“;
if($isP1 == 1)
{
echo “

“;
echo “

“;
echo “

“;
}
else
{
echo “

“;
echo “

“;
echo “

“;
}
echo “

“;
}
echo “

CompetitionYearResultOpponentFA
“.$row[‘comp’].”“.$row[‘year’].”$result“.$row[‘player2’].”“.$row[‘score1’].”“.$row[‘score2’].”“.$row[‘player1’].”“.$row[‘score2’].”“.$row[‘score1’].”

“;
$dbh= null;
}
catch(PDOException $e) { echo $e; }
}
[/insert_php]