Created
December 7, 2014 16:24
-
-
Save kotarot/3e1e369d4f80deb128bf to your computer and use it in GitHub Desktop.
For my blog article.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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