All pastes #250803 Raw Edit

Mine

public php v1 · immutable
#250803 ·published 2006-11-17 11:20 UTC
rendered paste body
	if ($_SERVER['REQUEST_METHOD'] == "POST") {		if ($_POST['operation'] == "enterMatchStats") {			echo "<form action=\"admin.php\" method=\"post\">";			$sql = new SQL();			$sql->connect('kok_ncsl3');			$result = $sql->query("SELECT gid, home_tid, away_tid FROM game WHERE gid = {$_POST['gid']}");					while ($row = mysql_fetch_array($result)) {				$hometeam = $row['home_tid'];				$awayteam = $row['away_tid'];			}?>			<table>			<tr>				<th colspan="5"><?php echo getTeamNameFromTID($hometeam); ?></th>			</tr>			<tr>				<td>Rounds Won</td>				<td><input type="text" name="home_score" size="4" /></td>			</tr>			<tr>				<th>Username</th>				<th>Played</th>				<th>Rounds Played</th>				<th>Kills</th>				<th>Deaths</th>			</tr><?php			$result = $sql->query("SELECT pid, name FROM player WHERE tid = {$hometeam}");			echo mysql_error();			$counter = 0;			while($row = mysql_fetch_array($result))			{?>				<tr>				<td><?php echo $row['name'] ?></td>				<td><input name="home_played[<?php echo $counter; $counter++; ?>]" type="checkbox" value="played" /></td>				<td><input name="home_rounds[]" type="text" size="5" /></td>				<td><input name="home_kills[]" type="text" size="5" /></td>				<td><input name="home_deaths[]" type="text" size="5" /></td>				<input name="home_pids[]" value="<?php echo $row['pid'] ?>" type="hidden" />				</tr><?php			}			echo "</table>";?>			<br />			<table>			<tr>				<th colspan="5"><?php echo getTeamNameFromTID($awayteam); ?></th>			</tr>			<tr>				<td>Rounds Won</td>				<td><input type="text" name="away_score" size="4" /></td>			</tr>			<tr>				<th>Username</th>				<th>Played</th>				<th>Rounds played</th>				<th>Kills</th>				<th>Deaths</th>			</tr><?php			$counter = 0;			$result = $sql->query("SELECT pid, tid, name FROM player WHERE tid = {$awayteam}");			while($row = mysql_fetch_array($result))			{?>				<tr>				<td><?php echo $row['name']; ?></td>				<td><input name="away_played[<?php echo $counter; $counter++; ?>]" type="checkbox" value="played" /></td>				<td><input name="away_rounds[]" type="text" size="5" /></td>				<td><input name="away_kills[]" type="text" size="5" /></td>				<td><input name="away_deaths[]" type="text" size="5" /></td>				<input name="away_pids[]" value="<?php echo $row['pid']; ?>" type="hidden" />				<input name="gid" value="<?php echo $_POST['gid']; ?>" type="hidden" />				</tr><?php			}?>			</table>			<input type="hidden" name="action" value="enterMatchStats" />			<input type="hidden" name="operation" value="submitMatchStats" />			<input type="submit" value="Save">			</form><?php		}		elseif ($_POST['operation'] == "submitMatchStats") {			echo "<div align=\"left\"><pre>";			echo print_r($_POST);			echo "</pre></div>";						setTeamStats($_POST['gid'], $_POST['home_score'], $_POST['away_score']);error_reporting(E_ALL);			/*foreach ($_POST['home_pids'] as $index => $pid) {				if ($_POST['home_played'][$index] == "played") {					setPlayerStats($_POST['gid'], $pid, $_POST['home_rounds'][$index], $_POST['home_kills'][$index], $_POST['home_deaths'][$index]);				}			}						foreach ($_POST['away_pids'] as $index => $pid) {				if ($_POST['away_played'][$index] == "played") {					setPlayerStats($_POST['gid'], $pid, $_POST['away_rounds'][$index], $_POST['away_kills'][$index], $_POST['away_deaths'][$index]);				}			}*/			foreach ($_POST['home_played'] as $index) {				if ($_POST['home_played'][$index] == "played") {					setPlayerStats($_POST['gid'], $_POST['home_pids'][$index], $_POST['home_rounds'][$index], $_POST['home_kills'][$index], $_POST['home_deaths'][$index]);				}			}			foreach ($_POST['away_played'] as $index) {				if ($_POST['away_played'][$index] == "played") {					setPlayerStats($_POST['gid'], $_POST['away_pids'][$index], $_POST['away_rounds'][$index], $_POST['away_kills'][$index], $_POST['away_deaths'][$index]);				}			}			echo "Player stats added successfully.";		}	}