Skip to content

Instantly share code, notes, and snippets.

@kotarot
Created December 7, 2014 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotarot/3e1e369d4f80deb128bf to your computer and use it in GitHub Desktop.
Save kotarot/3e1e369d4f80deb128bf to your computer and use it in GitHub Desktop.
For my blog article.
<?php
// Definitions by the user.
define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', '********');
define('MYSQL_PASS', '********');
define('MYSQL_DB', '********');
// DB connection without error handlings.
$link = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
$db = mysql_select_db(MYSQL_DB, $link);
mysql_set_charset('utf8');
// An example SQL query.
// Counts competitions in which all competitors in the podiums of 333bf achieved sub-X,
// where X=90, downto, 30.
for ($s = 90; $s >= 30; $s -= 10) {
$sql = "SELECT COUNT(*) FROM `Results`
WHERE eventId='333bf' AND roundId='f' AND pos=3 AND 0<best AND best<${s}00";
$result = mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_NUM);
echo "All in the podium achieved sub${s}: " . $row[0] . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment