Vote for Your College
Bring Ali’s Power Hour Drinking Game Concert to you!
[php]
if ($_GET[“verified”]) {
print “[div class=’thanks’]Thanks! Your vote has been registered![/div][br /]”;
}
if ($_GET[“thanks”]) {
print “[div class=’thanks’][a href=’http://www.powerhouralbum.com’ target=’_blank’][img src=’/powerhour/img/thanks-banner.jpg’/][/a][/div][br /][div class=’addthis_toolbox addthis_default_style ‘ addthis:url=’http://www.alispagnola.com/powerhour/college/’ addthis:title=’College Voting ‘ ][a class=’addthis_button_facebook_like’ fb:like:layout=’button_count’][/a][a class=’addthis_button_tweet’][/a][a class=’addthis_counter addthis_pill_style’][/a][/div]”;
}
[/php]
I won a contest that requires me to spend a big wad of cash on an epic party. The college that wants it the most gets it!


 

[php]
date_default_timezone_set(“America/New_York”);

// create the MySQL connection
$host = “mysql.aspagnola.com”;
$user = “alispagn_power”;
$pass = “knioy125”;
$database = “alispagn_wordpresspowerhour”;
$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

// select the ranked results from DB
$voting_table = “college_voting_verified”;
$cheaters = “‘Michigan Technological University (MI)'”;
$select_query = “SELECT `college`, count(*) as `votes` from `$voting_table` where `verified` = 1 and `failed` = 0 and `college` not in ($cheaters) group by `college` order by `votes` desc, `college` asc”;
$select_cheaters_query = “SELECT `college`, count(*) as `votes` from `$voting_table` where `verified` = 1 and `failed` = 0 and `college` in ($cheaters) group by `college` order by `votes` desc, `college` asc”;

print “[div class=’ranking’]n”;

// build a table of cheater results
$cheaters_result = mysql_query($select_cheaters_query) or die(mysql_error());
print ” [table class=’ranking_table’]n”;
print ” [tr][th][span style=’color:#999999′]Rank[span][/th][th][span style=’color:#999999′]College (Hacking Winners)[span][/th][th][span style=’color:#999999′]Votes[span][/th][/tr]n”;
if ($cheaters_result) {
$last_votes_value = 0;
$index = 0;
while ($row = mysql_fetch_array($cheaters_result)) {
$college_value = $row[“college”];
$votes_value = $row[“votes”];
if ($votes_value > 0) {
if ($votes_value != $last_votes_value) {
//$index = $index + 1; // uncomment to increment count
}
$last_votes_value = $votes_value;
print ” [tr][td][span style=’color:#999999′]$index[span][/td][td][span style=’color:#999999′]$college_value[span][/td][td][span style=’color:#999999′]$votes_value[span][/td][/tr]n”;
}
}
}
else {
echo mysql_error();
}
print ” [/table]n”;

///////////////////////////////////////////////////////////////////////////
// Here’s where you can write PHP to generate the HTML between tables. //
// For example, //
// print “[a href=’http://someurl.com’]for a link[/a]n”; //
// will print an anchor tag. n prints a newline and to print a //
// double-quote, you can escape it with ” //

print ” [span style=’font-size: 9px’]Since there were a lot of schools cheating ([a href=’http://youtu.be/ZPRUsfHjwW8′ target=’_blank’]video about that here[/a]), I had to remove thousands of votes. As far as I can tell, MTU won with hundreds of legit votes. But I can’t be sure so MTU gets the “Hacker Award” and I’m playing a show there. (Stay tuned for details!) But I’m also [strong]EXTENDING THE CONTEST![/strong] Voting will continue and I’ll announce a voting deadline soon followed by ANOTHER WINNER. Yay![/span] [br /][br /]n[br /]n [h7]Leaderboard[/h7] n[br /]
[h8]Rank of the awesomest partiers[/h8]
“;

///////////////////////////////////////////////////////////////////////////

// build a table of valid results
$result = mysql_query($select_query) or die(mysql_error());
print ” [table class=’ranking_table’]n”;
print ” [tr][th]Rank[/th][th]College[/th][th]Votes[/th][/tr]n”;
if ($result) {
$last_votes_value = 0;
$index = 0;
while ($row = mysql_fetch_array($result)) {
$college_value = $row[“college”];
$votes_value = $row[“votes”];
if ($votes_value > 0) {
if ($votes_value != $last_votes_value) {
$index = $index + 1;
}
$last_votes_value = $votes_value;
print ” [tr][td]$index[/td][td]$college_value[/td][td]$votes_value[/td][/tr]n”;
}
}
}
else {
echo mysql_error();
}
print ” [/table]n”;

print “[/div]n”;

[/php]