File: /home/awaldron/public_html/aw/babypoll/index.php
<?php
function quickSQL($sql) {
$res = mysql_query($sql);
if (mysql_num_rows($res) == 1) {
$row = mysql_fetch_row($res);
return $row[0];
} else return FALSE;
}
function quickUPDATE($sql) {
if (mysql_query($sql) > 0) return $res;
else return FALSE;
}
$db = mysql_connect("localhost", "awaldron", "IamMine92");
if (!$db) { echo "Error: Could not connect to DB.<br>" . mysql_error(); exit; }
mysql_select_db("awaldron_awaldron");
?>
<html>
<head>
<title>Lincoln Hill Baby Poll</title>
</head>
<link rel="stylesheet" type="text/css" href="default.css">
<?php
$warning = "";
if (isset($_POST["submit"])) {
foreach ($_POST as $key => $value) {
if (($value != "") && ($key != "submit")) {
$key = explode("-",$key);
$curr = quickSQL("SELECT bet FROM babypoll WHERE min=".$key[1]);
if ($curr == "0") quickUPDATE("UPDATE babypoll SET bet='".$value."' WHERE min=".$key[1]);
else $warning .= "<li> Oops! Slot <b>:".($key[1]<10?"0".$key[1]:$key[1])."</b> is already taken by <b>".$curr."</b>!<br>\n";
}
}
}
echo "<body style=\"margin:15px;font-size:12px;\">\n";
$sql = "SELECT * FROM babypoll ORDER BY min ASC";
$res = mysql_query($sql);
echo "<P><span class=\"headline\"><i>Lincoln Hill Baby Poll</i></span>\n";
echo "<P><ul style=\"line-height:18px\">\n";
echo "<li>Pick the minute of the hour in which you think Lincoln will be born.\n";
echo "<li>Price is $1.00 per time slot.\n";
//echo "<li>You <u>MAY NOT</u> select consecutive time slots. (i.e. 24 & 25)<br><br>\n";
//echo "<li>50% of the prize pool ($60) will be awarded to the person who guesses the precise minute.\n";
echo "<li>If Linc is born on an unclaimed spot, he wins the money!</li><br><br>\n";
echo "<li><b>Type your first and last name in the desired slots below. Then click \"Place My Bet!\"</b>\n";
//echo "<li>Please only play if you're certain you can get the money to me by June 11.\n";
echo "</ul>\n";
echo "<table border=0 cellspacing=20 cellpadding=0><tr>\n";
echo "<form action=\"index.php\" method=\"post\">\n";
if (isset($_POST["submit"]) && ($warning != "")) {
echo "<tr><td colspan=3 align=\"center\"><span style=\"color:#CC0000;\">".$warning."</span></td></tr>";
}
for ($i=0; $i < mysql_num_rows($res); $i++) {
$row = mysql_fetch_array($res);
if ($i%15==0) echo "<td valign=\"top\"><table border=0 cellspacing=0 cellpadding=4>\n";
echo "<tr>";
echo "<td><img src=\"clear.gif\" width=1 height=20></td>\n";
echo "<td style=\"color:#CC0000;\"><b>:".($row["min"]<10?"0".$row["min"]:$row["min"])."</b></td>";
if ($row["bet"]=="0") echo "<td width=200><input type=\"text\" name=\"bet-".$row["min"]."\" style=\"width:200px;\"></td>";
else echo "<td width=200><b>".$row["bet"]."</b></td>";
echo "</tr>\n";
if ($i%15==14) echo "</table></td>\n";
}
echo "</tr><tr><td colspan=4 align=\"center\"><input type=\"submit\" name=\"submit\" value=\" Place My Bet! \"></td></tr></table>\n";
echo "</form>\n";
?>