View Single Post
Old 09-04-2014, 01:37 AM   #3
Join Date: Sep 2014
Posts: 2
Default Submit a Repeat Region to Database

A little more specifics. I have as SQL query that works:

mysql_select_db($database_workrelated, $workrelated);
$query_RSWeek1Calc = "SELECT game_data.Username, ABS(game_data.Team1_SCR- 52) + ABS(game_data.Team2_SCR -14) AS OFFSET1, ABS(game_data.Team3_SCR - 34) + ABS(game_data.Team4_SCR -43) AS OFFSET2, ABS(game_data.Team1_SCR- 52) + ABS(game_data.Team2_SCR -14) + ABS(game_data.Team3_SCR - 34) + ABS(game_data.Team4_SCR -43) AS TOTAL, game_data.Team1_SCR, game_data.Team2_SCR, game_data.Team3_SCR, game_data.Team4_SCR FROM game_data WHERE Week = 1 AND Season = 1 ORDER BY TOTAL ";
$RSWeek1Calc = mysql_query($query_RSWeek1Calc, $workrelated) or die(mysql_error());
$row_RSWeek1Calc = mysql_fetch_assoc($RSWeek1Calc);
$totalRows_RSWeek1Calc = mysql_num_rows($RSWeek1Calc);
Then I have a Form i Created with a repeating Table that works:

<form method="POST" action="<?php echo $editFormAction; ?>" name="form"><?php do { ?>
<table align="center" border="1" >
<tbody style="text-align: center">
<tr align="center" >
<td width="225" scope="col"><?php echo $row_RSWeek1Calc['Username']; ?></td>
<td width="100" scope="col" ><?php echo $row_RSWeek1Calc['Team1_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team2_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team3_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['Team4_SCR']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['OFFSET1']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['OFFSET2']; ?></td>
<td width="100" scope="col"><?php echo $row_RSWeek1Calc['TOTAL']; ?></td>
<?php } while ($row_RSWeek1Calc = mysql_fetch_assoc($RSWeek1Calc)); ?><input type="submit"><input name="offset1" type="hidden" id="offset1" value="<?php echo $row_RSWeek1Calc['OFFSET1']; ?>"><input name="offset2" type="hidden" id="offset2" value="<?php echo $row_RSWeek1Calc['OFFSET2']; ?>"><input name="total" type="hidden" id="total" value="<?php echo $row_RSWeek1Calc['TOTAL']; ?>"><input name="correctPicks" type="hidden" id="correctPicks" value="<?php echo $row_rsAdmin['']; ?>"><input name="Pts" type="hidden" id="Pts" value="10">
<input type="hidden" name="MM_insert" value="form">
<input name="username" type="hidden" id="username" value="<?php echo $row_RSWeek1Calc['Username']; ?>">
<input name="scr1" type="hidden" id="scr1" value="<?php echo $row_RSWeek1Calc['Team1_SCR']; ?>">
<input name="scr2" type="hidden" id="scr2" value="<?php echo $row_RSWeek1Calc['Team2_SCR']; ?>">
<input name="scr4" type="hidden" id="scr4" value="<?php echo $row_RSWeek1Calc['Team4_SCR']; ?>">
<input name="week" type="hidden" id="week" value="1">
<input name="season" type="hidden" id="season" value="1">
<input name="email" type="hidden" id="email" value="<?php echo $row_rsAdmin['Email']; ?>">
<input name="locked" type="hidden" id="locked" value="YES">
I am attempting to echo all the returned results and submit all the fields to another Table in the database. But although I can see the whole table, I get "null" values on the above. I believe this is not a abnormal thing to want to do and it is probably simple...but I am currently unsuccessful.

This is the code on the Submit button:

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO game_calc (UserID, Username, Season, Week, Team1_SCR, Team2_SCR, Team3_SCR, Team4_SCR, Game1_OFFSET, Game2_OFFSET, `Total OFFSET`, `Correct Picks`, `PTS EARNED`, Locked) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['season'], "int"),
GetSQLValueString($_POST['week'], "int"),
GetSQLValueString($_POST['scr1'], "int"),
GetSQLValueString($_POST['scr2'], "int"),
GetSQLValueString($_POST['scr3'], "int"),
GetSQLValueString($_POST['scr4'], "int"),
GetSQLValueString($_POST['offset1'], "int"),
GetSQLValueString($_POST['offset1'], "int"),
GetSQLValueString($_POST['total'], "int"),
GetSQLValueString($_POST['correctPicks'], "int"),
GetSQLValueString($_POST['Pts'], "int"),
GetSQLValueString($_POST['locked'], "text"));

mysql_select_db($database_workrelated, $workrelated);
$Result1 = mysql_query($insertSQL, $workrelated) or die(mysql_error());
L.O.F.T. is offline   Reply With Quote