I read through the other post and was not able to glean anything out of it that I have not already tried over the last week of working on this. I have tried both check boxes and list/menus as well. It's not a hard problem and I am sure I am missing one small thing. The page is where a member is brought to change their teams lineup in the MySQL database. They are allowed to see their players only if they are logged in, hence all the gibberish in the top two queries. They would select active or bench from the check box or drop down list for each player and hit the submit button, which should change the value of that column to the forms selections. Nothing happening...can you help?
Thanks Scott
CODE:
<?php require('/conn.php'); ?>
<?php
session_start();
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
$colname_DetailRS1 = "-1";
if (isset($SESSION['MM_Username'])) {
$colname_DetailRS1 = $SESSION['MM_Username'];
}
mysql_select_db($database_conn_ssfhl, $conn_ssfhl);
$query_DetailRS1 = sprintf("SELECT PlayerID, FanID, Type, InjuryID, Player, StatusID, StatusChangeChoice, CurrentWeek, GMEmail FROM tblplayers WHERE GMEmail = %s ORDER BY tblplayers.Type Asc", GetSQLValueString($colname_DetailRS1, "text"));
$DetailRS1 = mysql_query($query_DetailRS1, $conn_ssfhl) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
$colname_rsGMDetail = "-1";
if (isset($SESSION['MM_Username'])) {
$colname_rsGMDetail = $SESSION['MM_Username'];
}
mysql_select_db($database_conn_ssfhl, $conn_ssfhl);
$query_rsGMDetail = sprintf("SELECT GMFirst, GMLast FROM tbluseradmin WHERE GMEmail = %s", GetSQLValueString($colname_rsGMDetail, "text"));
$rsGMDetail = mysql_query($query_rsGMDetail, $conn_ssfhl) or die(mysql_error());
$row_rsGMDetail = mysql_fetch_assoc($rsGMDetail);
$totalRows_rsGMDetail = mysql_num_rows($rsGMDetail);
?>
<?php
// If form has been submitted
if (isset($POST['status']))
{
// Post variables
$status = $POST['status'];
$count = count($status);
$i = 0;
while ($i < $n)
{
echo "<li>{$status[$i]}</li> \r\n";
$i++;
}
}
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="rosterupdate" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<tr class="stattable">
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr class="statshdr">
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Position</strong></td>
<td align="center"><strong>Player</strong></td>
<td align="center"><strong>Health</strong></td>
<td align="center"><strong>Current_Roster_Status</strong></td>
<td align="center"><strong>Update_Roster_Status</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($DetailRS1)){
?>
<tr>
<td align="center"><? $id[]=$rows['PlayerID']; ?><? echo $rows['PlayerID']; ?></td>
<td align="center"><strong><? echo $rows['Type']; ?></strong></td>
<td align="left" nowrap="nowrap"><strong><? echo $rows['Player']; ?></strong></td>
<td align="center"><strong><? echo $rows['InjuryID']; ?></strong></td>
<td align="left"><div align="center"><strong><? echo $rows['StatusID']; ?></strong></div></td>
<td align="center" nowrap="nowrap"><label>
<input name="status[]" type="checkbox" value="Active" checked="checked" />
Active
<input name="status[]" type="checkbox" value="Bench" />
Bench</label>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="submit" value="Submit Changes"></td>
</tr>
</table>
</form>
</table>
<p>
<?php
// Check if button name "Submit" is active, do this
if(isset($POST['submit']))
{
// Update the database with the new information
for($i=0;$i<$count;$i++){
$status_array= $POST['status'];//[$i];
$id = $_POST['PlayerID'];//[$i];
$update="UPDATE tblplayers SET tblplayers.StatusChangeChoice = '$status' WHERE tblplayers.PlayerID = '$id'";
$result1=mysql_query($update);
}
}
//if($result1){
//header("location: rostersubmitted.php");
//}
mysql_close();
?>