User prioritizing a table array

Added that, got nothing

now cause an error after it…

type in…

abc=123

leave off the semi-colon…

what happens?

Parse error: syntax error, unexpected ‘=’ in blablabla/picker/entry_formweighted.php on line 6

Do this…

Add this just above your post action

[php]echo $_POST[‘action’];
exit;
if ($_POST[‘action’] == ‘Submit’) {[/php]

Whats the output, I have a feeling it’s never entering your loop.

If I move the syntax error inside of the if statement, it does halt it ----- but if I put an exit, die or sleep and push the submit, it does nothing.

got a blank screen from that

Perfect, that’s what I thought…

That means the $_POST[‘action’] doesn’t = ‘Submit’, it’s not set and it doesn’t enter the loop. Therefore, it never hits all your other exits.

But if I change my radio button picks and hit submit it does change the table to the new pick, but never hits the exits (or writes the points) ???

It also modifies the show picks to others in the pickssummary table which is inside the if statement.

can you post the entry_form.php file?

I take it you mean the original before my hands got on it. Well I did mod this one too, but only for displaying picks from previous weeks that wasn’t working right from the original author.

[php]<?php
require_once(‘includes/application_top.php’);
require(‘includes/classes/team.php’);

if ($_POST[‘action’] == ‘Submit’) {
$week = $_POST[‘week’];
$cutoffDateTime = getCutoffDateTime($week);

//update summary table
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());

//loop through non-expire weeks and update picks
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "')";
		mysql_query($sql) or die('Error inserting pick: ' . mysql_error());
	}
}
header('Location: results.php?week=' . $_POST['week']);

} else {
$week = (int)$_GET[‘week’];
if (empty($week)) {
//get current week
$week = (int)getCurrentWeek();
}
$cutoffDateTime = getCutoffDateTime($week);
$firstGameTime = getFirstGameTime($week);
}

include(‘includes/header.php’);
include(‘includes/column_right.php’);

//display week nav
$sql = "select distinct weekNum from " . $db_prefix . “schedule order by weekNum;”;
$query = mysql_query($sql);
$weekNav = '

Go to week: ';
$i = 0;
while ($result = mysql_fetch_array($query)) {
if ($i > 0) $weekNav .= ’ | ';
if ($week !== (int)$result[‘weekNum’]) {
$weekNav .= ‘’ . $result[‘weekNum’] . ‘’;
} else {
$weekNav .= $result[‘weekNum’];
}
$i++;
}
$weekNav .= ‘
’ . “\n”;
echo $weekNav;
?>
			<h2>Week <?php echo $week; ?> - Make Your Picks:</h2>
			<p>Make your picks below by clicking on the team helmet or checking the radio buttons to the right.</p>
			<script type="text/javascript">
			function checkform() {
				//make sure all picks have a checked value
				var f = document.entryForm;
				var allChecked = true;
				var allR = document.getElementsByTagName('input');
				for (var i=0; i < allR.length; i++) {
					if(allR[i].type == 'radio') {
						if (!radioIsChecked(allR[i].name)) {
							allChecked = false;
						}
					}      
			    }
			    if (!allChecked) {
					return confirm('One or more picks are missing for the current week.  Do you wish to submit anyway?');
				}
				return true;
			}
			function radioIsChecked(elmName) {
				var elements = document.getElementsByName(elmName);
				for (var i = 0; i < elements.length; i++) {
					if (elements[i].checked) {
						return true;
					}
				}
				return false;
			}
			</script>
<div style="float: right; width: 270px; margin-right: 10px"><?php include('includes/comments.php'); ?></div>
<?php
//get existing picks
$picks = getUserPicks($week, $user->userID);

//get show picks status
$sql = "select * from " . $db_prefix . "picksummary where weekNum = " . $week . " and userID = " . $user->userID . ";";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	$result = mysql_fetch_array($query);
	$showPicks = (int)$result['showPicks'];
} else {
	$showPicks = 1;
}

//display schedule for week
$sql = "select s.*, (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > gameTimeEastern or DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > '" . $cutoffDateTime . "')  as expired ";
$sql .= "from " . $db_prefix . "schedule s ";
$sql .= "inner join " . $db_prefix . "teams ht on s.homeID = ht.teamID ";
$sql .= "inner join " . $db_prefix . "teams vt on s.visitorID = vt.teamID ";
$sql .= "where s.weekNum = " . $week . " ";
$sql .= "order by s.gameTimeEastern, s.gameID";
//echo $sql;
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	echo '<form name="entryForm" action="entry_form.php" method="post" onsubmit="return checkform();">' . "\n";
	echo '<input type="hidden" name="week" value="' . $week . '" />' . "\n";
	echo '<table cellpadding="4" cellspacing="0" class="table1">' . "\n";
	//echo '	<tr><th>Home</th><th>Visitor</th><th align="left">Game</th><th>Time / Result</th><th>Your Pick</th></tr>' . "\n";
	$i = 0;
	while ($result = mysql_fetch_array($query)) {
		$homeTeam = new team($result['homeID']);
		$visitorTeam = new team($result['visitorID']);
		$rowclass = (($i % 2 == 0) ? ' class="altrow"' : '');
		//$pickExpired = ((date("U") > strtotime($result['gameTimeEastern'])) ? true : false);
		echo '		<tr' . $rowclass . '>' . "\n";
		echo '			<td align="center">' . "\n";
		echo '				<table width="100%" border="0" cellpadding="2" cellspacing="0" class="nostyle">' . "\n";
		echo '					<tr valign="middle">' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $visitorTeam->teamID . '"><img src="images/helmets_big/' . strtolower($visitorTeam->teamID) . '1.gif" onclick="document.entryForm.game' . $result['gameID'] . '[0].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $visitorTeam->city . ' ' . $visitorTeam->team . '</b><br />Record: ' . getTeamRecord($visitorTeam->teamID) . '<br />Streak: ' . getTeamStreak($visitorTeam->teamID) . '</span></td>' . "\n";
		echo '						<td align="center">at</td>' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $homeTeam->teamID . '"><img src="images/helmets_big/' . strtolower($homeTeam->teamID) . '2.gif" onclick="document.entryForm.game' . $result['gameID'] . '[1].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $homeTeam->city . ' ' . $homeTeam->team . '</b><br />Record: ' . getTeamRecord($homeTeam->teamID) . '<br />Streak: ' . getTeamStreak($homeTeam->teamID) . '</span></td>' . "\n";
		echo '					</tr>' . "\n";
		if (strlen($result['homeScore']) > 0 && strlen($result['visitorScore']) > 0) {
			//if score is entered, show score
                    $scoreEntered = TRUE;
			echo '					<tr><td colspan="3" align="center"><b>Final: ' . $result['visitorScore'] . ' - ' . $result['homeScore'] . '</b></td></tr>' . "\n";
		} else {
			//else show time of game
			echo '					<tr><td colspan="3" align="center">' . date('D n/j g:i a', strtotime($result['gameTimeEastern'])) . ' ET</td></tr>' . "\n";
		}
		echo '				</table>' . "\n";
		echo '			</td>' . "\n";
		echo '			<td align="left"><b>Your Pick:</b><br />' . "\n";
		if (!$result['expired']) {
			//if game is not expired, show pick
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $visitorTeam->teamID . '" id="' . $result['gameID'] . $visitorTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $visitorTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $visitorTeam->teamID . '">' . $visitorTeam->teamName . '</label><br />' . "\n";
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $homeTeam->teamID . '" id="' . $result['gameID'] . $homeTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $homeTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $homeTeam->teamID . '">' . $homeTeam->teamName . '</label><br />' . "\n";
		} else {
			//else show locked pick
			$pickID = getPickID($result['gameID'], $user->userID);
			if (!empty($pickID)) {
				$statusImg = '';
				$pickTeam = new team($pickID);
				$pickLabel = $pickTeam->teamName;
			} else {
				$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
				$pickLabel = 'None Selected';
			}
			if ($scoreEntered) {
				//set status of pick (correct, incorrect)

$winnerid = ‘’;
if ($result[‘homeScore’] > $result[‘visitorScore’]) { $winnerid = $homeTeam->teamID; }else { $winnerid = $visitorTeam->teamID;}

				if ($pickID == $winnerid) {
					$statusImg = '<img src="images/check_16x16.png" width="16" height="16" alt="" />';
                                $pickpoints = $picks[$result['gameID']]['points'];
				} else {
					$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
					$pickpoints = 0;
				}
			}
			echo '			' . $statusImg . ' ' . $pickLabel . "\n";
			
                    echo '                 <BR><B>Points/Possible: ' . $pickpoints. ' / ' . $picks[$result['gameID']]['points'] . '</B>' ."\n";

		}
		echo '			</td>' . "\n";
		echo '		</tr>' . "\n";
		$i++;
	}
	echo '</table>' . "\n";
	echo '<p><input type="checkbox" name="showPicks" id="showPicks" value="1"' . (($showPicks) ? ' checked="checked"' : '') . ' /> <label for="showPicks">Allow others to see my picks</label></p>' . "\n";
	echo '<p><input type="submit" name="action" value="Submit" /></p>' . "\n";
	echo '</form>' . "\n";
}
?>
<?php include('includes/footer.php'); ?>[/php]

Here is the raw original

[php]<?php
require_once(‘includes/application_top.php’);
require(‘includes/classes/team.php’);

if ($_POST[‘action’] == ‘Submit’) {
$week = $_POST[‘week’];
$cutoffDateTime = getCutoffDateTime($week);

//update summary table
$sql = "delete from " . $db_prefix . "picksummary where weekNum = " . $_POST['week'] . " and userID = " . $user->userID . ";";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());
$sql = "insert into " . $db_prefix . "picksummary (weekNum, userID, showPicks) values (" . $_POST['week'] . ", " . $user->userID . ", " . (int)$_POST['showPicks'] . ");";
mysql_query($sql) or die('Error updating picks summary: ' . mysql_error());

//loop through non-expire weeks and update picks
$sql = "select * from " . $db_prefix . "schedule where weekNum = " . $_POST['week'] . " and (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < gameTimeEastern and DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) < '" . $cutoffDateTime . "');";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
	$sql = "delete from " . $db_prefix . "picks where userID = " . $user->userID . " and gameID = " . $result['gameID'];
	mysql_query($sql) or die('Error deleting picks: ' . mysql_error());
	
	if (!empty($_POST['game' . $result['gameID']])) {
		$sql = "insert into " . $db_prefix . "picks (userID, gameID, pickID) values (" . $user->userID . ", " . $result['gameID'] . ", '" . $_POST['game' . $result['gameID']] . "')";
		mysql_query($sql) or die('Error inserting pick: ' . mysql_error());
	}
}
header('Location: results.php?week=' . $_POST['week']);

} else {
$week = (int)$_GET[‘week’];
if (empty($week)) {
//get current week
$week = (int)getCurrentWeek();
}
$cutoffDateTime = getCutoffDateTime($week);
$firstGameTime = getFirstGameTime($week);
}

include(‘includes/header.php’);
include(‘includes/column_right.php’);

//display week nav
$sql = "select distinct weekNum from " . $db_prefix . “schedule order by weekNum;”;
$query = mysql_query($sql);
$weekNav = '

Go to week: ';
$i = 0;
while ($result = mysql_fetch_array($query)) {
if ($i > 0) $weekNav .= ’ | ';
if ($week !== (int)$result[‘weekNum’]) {
$weekNav .= ‘’ . $result[‘weekNum’] . ‘’;
} else {
$weekNav .= $result[‘weekNum’];
}
$i++;
}
$weekNav .= ‘
’ . “\n”;
echo $weekNav;
?>
			<h2>Week <?php echo $week; ?> - Make Your Picks:</h2>
			<p>Make your picks below by clicking on the team helmet or checking the radio buttons to the right.</p>
			<script type="text/javascript">
			function checkform() {
				//make sure all picks have a checked value
				var f = document.entryForm;
				var allChecked = true;
				var allR = document.getElementsByTagName('input');
				for (var i=0; i < allR.length; i++) {
					if(allR[i].type == 'radio') {
						if (!radioIsChecked(allR[i].name)) {
							allChecked = false;
						}
					}      
			    }
			    if (!allChecked) {
					return confirm('One or more picks are missing for the current week.  Do you wish to submit anyway?');
				}
				return true;
			}
			function radioIsChecked(elmName) {
				var elements = document.getElementsByName(elmName);
				for (var i = 0; i < elements.length; i++) {
					if (elements[i].checked) {
						return true;
					}
				}
				return false;
			}
			</script>
<div style="float: right; width: 270px; margin-right: 10px"><?php include('includes/comments.php'); ?></div>
<?php
//get existing picks
$picks = getUserPicks($week, $user->userID);

//get show picks status
$sql = "select * from " . $db_prefix . "picksummary where weekNum = " . $week . " and userID = " . $user->userID . ";";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	$result = mysql_fetch_array($query);
	$showPicks = (int)$result['showPicks'];
} else {
	$showPicks = 1;
}

//display schedule for week
$sql = "select s.*, (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > gameTimeEastern or DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > '" . $cutoffDateTime . "')  as expired ";
$sql .= "from " . $db_prefix . "schedule s ";
$sql .= "inner join " . $db_prefix . "teams ht on s.homeID = ht.teamID ";
$sql .= "inner join " . $db_prefix . "teams vt on s.visitorID = vt.teamID ";
$sql .= "where s.weekNum = " . $week . " ";
$sql .= "order by s.gameTimeEastern, s.gameID";
//echo $sql;
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
	echo '<form name="entryForm" action="entry_form.php" method="post" onsubmit="return checkform();">' . "\n";
	echo '<input type="hidden" name="week" value="' . $week . '" />' . "\n";
	echo '<table cellpadding="4" cellspacing="0" class="table1">' . "\n";
	//echo '	<tr><th>Home</th><th>Visitor</th><th align="left">Game</th><th>Time / Result</th><th>Your Pick</th></tr>' . "\n";
	$i = 0;
	while ($result = mysql_fetch_array($query)) {
		$homeTeam = new team($result['homeID']);
		$visitorTeam = new team($result['visitorID']);
		$rowclass = (($i % 2 == 0) ? ' class="altrow"' : '');
		//$pickExpired = ((date("U") > strtotime($result['gameTimeEastern'])) ? true : false);
		echo '		<tr' . $rowclass . '>' . "\n";
		echo '			<td align="center">' . "\n";
		echo '				<table width="100%" border="0" cellpadding="2" cellspacing="0" class="nostyle">' . "\n";
		echo '					<tr valign="middle">' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $visitorTeam->teamID . '"><img src="images/helmets_big/' . strtolower($visitorTeam->teamID) . '1.gif" onclick="document.entryForm.game' . $result['gameID'] . '[0].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $visitorTeam->city . ' ' . $visitorTeam->team . '</b><br />Record: ' . getTeamRecord($visitorTeam->teamID) . '<br />Streak: ' . getTeamStreak($visitorTeam->teamID) . '</span></td>' . "\n";
		echo '						<td align="center">at</td>' . "\n";
		echo '						<td align="center"><label for="' . $result['gameID'] . $homeTeam->teamID . '"><img src="images/helmets_big/' . strtolower($homeTeam->teamID) . '2.gif" onclick="document.entryForm.game' . $result['gameID'] . '[1].checked=true;" /></label><br /><span style="font-size: 9px;"><b>' . $homeTeam->city . ' ' . $homeTeam->team . '</b><br />Record: ' . getTeamRecord($homeTeam->teamID) . '<br />Streak: ' . getTeamStreak($homeTeam->teamID) . '</span></td>' . "\n";
		echo '					</tr>' . "\n";
		if (strlen($result['homeScore']) > 0 && strlen($result['visitorScore']) > 0) {
			//if score is entered, show score
			echo '					<tr><td colspan="3" align="center"><b>Final: ' . $result['visitorScore'] . ' - ' . $result['homeScore'] . '</b></td></tr>' . "\n";
		} else {
			//else show time of game
			echo '					<tr><td colspan="3" align="center">' . date('D n/j g:i a', strtotime($result['gameTimeEastern'])) . ' ET</td></tr>' . "\n";
		}
		echo '				</table>' . "\n";
		echo '			</td>' . "\n";
		echo '			<td align="left"><b>Your Pick:</b><br />' . "\n";
		if (!$result['expired']) {
			//if game is not expired, show pick
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $visitorTeam->teamID . '" id="' . $result['gameID'] . $visitorTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $visitorTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $visitorTeam->teamID . '">' . $visitorTeam->teamName . '</label><br />' . "\n";
			echo '			<input type="radio" name="game' . $result['gameID'] . '" value="' . $homeTeam->teamID . '" id="' . $result['gameID'] . $homeTeam->teamID . '"' . (($picks[$result['gameID']]['pickID'] == $homeTeam->teamID) ? ' checked="checked"' : '') . ' /> <label for="' . $result['gameID'] . $homeTeam->teamID . '">' . $homeTeam->teamName . '</label><br />' . "\n";
		} else {
			//else show locked pick
			$pickID = getPickID($result['gameID'], $user->userID);
			if (!empty($pickID)) {
				$statusImg = '';
				$pickTeam = new team($pickID);
				$pickLabel = $pickTeam->teamName;
			} else {
				$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
				$pickLabel = 'None Selected';
			}
			if ($scoreEntered) {
				//set status of pick (correct, incorrect)
				if ($pickID == $result['winnerID']) {
					$statusImg = '<img src="images/check_16x16.png" width="16" height="16" alt="" />';
				} else {
					$statusImg = '<img src="images/cross_16x16.png" width="16" height="16" alt="" />';
				}
			}
			echo '			' . $statusImg . ' ' . $pickLabel . "\n";
		}
		echo '			</td>' . "\n";
		echo '		</tr>' . "\n";
		$i++;
	}
	echo '</table>' . "\n";
	echo '<p><input type="checkbox" name="showPicks" id="showPicks" value="1"' . (($showPicks) ? ' checked="checked"' : '') . ' /> <label for="showPicks">Allow others to see my picks</label></p>' . "\n";
	echo '<p><input type="submit" name="action" value="Submit" /></p>' . "\n";
	echo '</form>' . "\n";
}
?>
<?php include('includes/footer.php'); ?>[/php]

[php]Parse error: syntax error, unexpected ‘=’ in blablabla/picker/entry_formweighted.php on line 6[/php]

Then what is entry_formweighted.php?

entry_formweighted.php is the one I am trying to change from entry_form.php to where you can select the points 1 through 15 (or however many games there are that week) so each player’s picks are confidence weighted.

the original version each game was worth one point (makes for alot of ties).

I got the math to work for it in all the other files, I just can’t get my input field for points to pass to the picks table. If I write them in from phpmyadmin, everything works. Just need the entry form to accept point value inputs and pass them to the picks table.

Do you want me to put the downloadable package up?

entry_form is in use, entry_formweighted has to be browsed to but will replace entry_form if can ever get it right.

I understand now…

You have the original and modified code…

So with the exit above the post action you get a blank screen when it first loads… as expected

Now try this, what happens?

[php] if (isset($_POST[‘action’]))
{
echo $_POST[‘action’];
exit;
}
if ($_POST[‘action’] == ‘Submit’) {
[/php]

doesn’t exit

This makes no sense to me, cause it appears the $_POST[‘action’] is always blank, but apparently you say the database updates…

Ask JimL to help, he’s 10x the coder I am in php.

Maybe this doesn’t belong in the beginner section, thought it did since I am a novice :o

It has to be updating from somewhere else, I’ve gone through most of the files and can’t find where, but I don’t always know what to look for.

Why it kicks to results.php even with the header line removed or commented out has to have something to do with it too.

if anyone wants to look at the whole package.

I put the package at http://elginturners.org/picker/Pickem.zip

I got it, it was sending it to entry_form.php instead of back to itself at entry_formweighted.php. You asked and I didn’t quite understand, thank you for your help.

Now I just got to get it to only accept 1 through # of games as points without repeating, maybe tomorrow.

That’s awesome.

I knew something wasn’t adding up right. I was just about to download your files and go through it.

Sponsor our Newsletter | Privacy Policy | Terms of Service