Here's the code.
- It updates my table sometimes which iis very odd!
<?php require_once('Connections/PFHL.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "UpdateEast")) {
$updateSQL = sprintf("UPDATE standings SET Games=%s, Wins=%s, Ties=%s, Losses=%s, Points=%s WHERE TeamID=%s",
GetSQLValueString($HTTP_POST_VARS['Games'], "int"),
GetSQLValueString($HTTP_POST_VARS['Wins'], "int"),
GetSQLValueString($HTTP_POST_VARS['Ties'], "int"),
GetSQLValueString($HTTP_POST_VARS['Losses'], "int"),
GetSQLValueString($HTTP_POST_VARS['Points'], "int"),
GetSQLValueString($HTTP_POST_VARS['TeamID'], "int"));
mysql_select_db($database_PFHL, $PFHL);
$Result1 = mysql_query($updateSQL, $PFHL) or die(mysql_error());
}
mysql_select_db($database_PFHL, $PFHL);
$query_UpdateEast = "SELECT * FROM standings WHERE standings.Conference = 'Eastern' ORDER BY standings.Points DESC";
$UpdateEast = mysql_query($query_UpdateEast, $PFHL) or die(mysql_error());
$row_UpdateEast = mysql_fetch_assoc($UpdateEast);
$totalRows_UpdateEast = mysql_num_rows($UpdateEast);
?>
<html>
<head></head>
<body>
<form method="POST" action="<?php echo $editFormAction; ?>" name="UpdateEast">
<table>
<tr>
<td> </td>
<td>Team</td>
<td>Games</td>
<td>Wins</td>
<td>Ties</td>
<td>Losses</td>
<td>Points</td>
<td>Division</td>
<td>Conference</td>
</tr>
<?php do { ?>
<tr>
<td><input type="hidden" name="TeamID" value="<?php echo $row_UpdateEast['TeamID']; ?>"></td>
<td><?php echo $row_UpdateEast['Team']; ?></td>
<td><input type="text" name="Games" value="<?php echo $row_UpdateEast['Games']; ?>"></td>
<td><input type="text" name="Wins" value="<?php echo $row_UpdateEast['Wins']; ?>"></td>
<td><input type="text" name="Ties" value="<?php echo $row_UpdateEast['Ties']; ?>"></td>
<td><input type="text" name="Losses" value="<?php echo $row_UpdateEast['Losses']; ?>"></td>
<td><input type="text" name="Points" value="<?php echo $row_UpdateEast['Points']; ?>"></td>
<td><?php echo $row_UpdateEast['Division']; ?></td>
<td><?php echo $row_UpdateEast['Conference']; ?></td>
</tr>
<?php } while ($row_UpdateEast = mysql_fetch_assoc($UpdateEast)); ?>
<tr>
<td><input type="submit" value="Update" name="MM_update"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="UpdateEast">
</form>
</body>
</html>
<?php
mysql_free_result($UpdateEast);
?>