Could someone help me figure out why this isn't working?
My update function isn't working on my php code. I have a breaking point that lists all the information at the end of the for loops, which is correct information. However it prints it about 50 times per ID. Also, it doesn't update the SQL table.
How could I fix this?
Snippet:
if ( isset( $_POST[ 'RemarketingRollCall' ] ) )
{
echo 'RollCall called ';
foreach($_POST['userid'] as $param1){
foreach($_POST['name'] as $param2){
foreach($_POST['job'] as $param3){
foreach($_POST['monday'] as $param4){
foreach($_POST['tuesday'] as $param5){
foreach($_POST['wednesday'] as $param6){
foreach($_POST['thursday'] as $param7){
foreach($_POST['friday'] as $param8){
$idnumber = mysqli_real_escape_string( $con, $param1 );
$Name = mysqli_real_escape_string( $con, $param2 );
$Job = mysqli_real_escape_string( $con, $param3 );
$Monday = mysqli_real_escape_string( $con, $param4 );
$Tuesday = mysqli_real_escape_string( $con, $param5 );
$Wednesday = mysqli_real_escape_string( $con, $param6 );
$Thursday = mysqli_real_escape_string( $con, $param7 );
$Friday = mysqli_real_escape_string( $con, $param8 );
echo "(". $idnumber . " " . $Name . " " . $Job . " " . $Monday . " " . $Tuesday . " " . $Wednesday . " " . $Thursday . " " . $Friday . ")";
$sql = "UPDATE `Employee` SET `Job`='$Job', `Monday`='$Monday', `Tuesday`='$Tuesday', `Wednesday`='$Wednesday', `Thursday`='$Thursday', `Friday`='$Friday' WHERE `ID`=$idnumber";
mysqli_query($con,$sql);
if ( !mysqli_query( $con, $sql ) )
{
die( 'Error: ' . mysqli_error( $con ) );
}
}
}
}
}
}
}
}
}
mysqli_close( $con );
?>
//putting a script here
This is the output: http://gyazo.com/3006df320d4857314ea486936f656ba3
Here is my table generation:
while($row = mysqli_fetch_array($remarketingRoll)) {
echo "<form id='RemarketingRollCall' method='POST'>";
echo "<tr>";
echo "<td contenteditable='false' align='center' width='11%'><input style='verticle-align:center;' type='text' name='userId[]' value=". $row['userId'] ." readonly></td>";
echo "<td contenteditable='false' align='center' width='11%'><input style='verticle-align:center;' type='text' name='name[]' value=". $row['Name'] ." readonly></td>";
echo "<td contenteditable='false' align='center' width='11%'>
<select name='job[]'>
<option value='Remarketing'>Remarketing</option>
<option value='IOS'>IOS</option>
<option value='Computers'>Computers</option>
</select></td>";
if ( strcmp( $row['Monday'], 'Attended' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='monday[]'>
<option value='Attended''>Attended</option>
<option value='Absent'>Absent</option>
</select></td>";
} else if ( strcmp( $row['Monday'], 'Absent' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='monday[]'>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
} else {
echo "<td contenteditable='false' align='center' width='11%'>
<select name='monday[]'>
<option> </option>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
}
if ( strcmp( $row['Tuesday'], 'Attended' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='tuesday[]'>
<option value='Attended''>Attended</option>
<option value='Absent'>Absent</option>
</select></td>";
} else if ( strcmp( $row['Tuesday'], 'Absent' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='tuesday[]'>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
} else {
echo "<td contenteditable='false' align='center' width='11%'>
<select name='tuesday[]'>
<option> </option>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
}
if ( strcmp( $row['Wednesday'], 'Attended' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='wednesday[]'>
<option value='Attended''>Attended</option>
<option value='Absent'>Absent</option>
</select></td>";
} else if ( strcmp( $row['Wednesday'], 'Absent' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='wednesday[]'>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
} else {
echo "<td contenteditable='false' align='center' width='11%'>
<select name='wednesday[]'>
<option> </option>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
}
if ( strcmp( $row['Thursday'], 'Attended' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='thursday[]'>
<option value='Attended''>Attended</option>
<option value='Absent'>Absent</option>
</select></td>";
} else if ( strcmp( $row['Thursday'], 'Absent' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='thursday[]'>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
} else {
echo "<td contenteditable='false' align='center' width='11%'>
<select name='thursday[]'>
<option> </option>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
}
if ( strcmp( $row['Friday'], 'Attended' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='friday[]'>
<option value='Attended''>Attended</option>
<option value='Absent'>Absent</option>
</select></td>";
} else if ( strcmp( $row['Friday'], 'Absent' ) == 0 ){
echo "<td contenteditable='false' align='center' width='11%'>
<select name='friday[]'>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
} else {
echo "<td contenteditable='false' align='center' width='11%'>
<select name='friday[]'>
<option> </option>
<option value='Absent'>Absent</option>
<option value='Attended''>Attended</option>
</select></td>";
}
echo "<td name='week[]' contenteditable='false' align='center' width='11%'>" . $row['Week'] . "</td>";
echo "</tr>";
echo "</form>";
}