I am going to ask a question about the problem that I have, and try to figure it out based on your guys. I will send the source code if I REALLY cannot get it, but here I go ...
So, I have a form that displays the fields vertically. All this is a drop-down menu, and at the very end is the submit button. There is sprinkled with javascript, which allows me to add a new line without refreshing the page. Thus, for each key, there are never as many $ _POST arrays. The key that excites me (well, all of them, but as soon as I earn it, it works for everyone) is a fall $_POST['monworkhours']. This is a drop-down list with a list of different hours of work. I believe the problem is that I need to scroll through the entire array $_POST['monworkhours']based on the view. I do not know how to do that.
In addition, the “problem” produces the same results for each line of output. Therefore, everything that I set for the first field becomes the result for each additional line that I added "through" through the javascript function.
Any help is appreciated.
The form:
<select name="monshifthours[]" id="monshifthours">
<option value="OFF">OFF</option>
<optgroup label="Front/Back Half">
<option value="7am7pm">7AM-7PM</option>
<option value="7pm7am">7PM-7AM</option>
<option value="7am7pmalt">7AM-7PM (Alt)</option>
<option value="7pm7amalt">7PM-7AM (Alt)</option>
</optgroup>
<optgroup label="Monday - Friday">
<option value="630am330pm">630AM-330PM</option>
<option value="7am4pm">7AM-4PM</option>
<option value="8am5pm">8AM-5PM</option>
<option value="10am7pm">10AM-7PM</option>
</optgroup>
</select>
The output of $ _POST (2 lines of lines):
["monshifthours"]=>
array(2) {
[0]=>
string(6) "7am7pm"
[1]=>
string(6) "7pm7am"
}
Screenshot:

GetCellColor () function:
function getCellColor($dow) {
foreach($_POST[$dow . 'shifthours'] as $key=> $hour) {
echo $count;
if ($hour == "7am7pmalt") {
return "style=\"background: yellow; color:#000;\"";
}
elseif ($hour == "OFF") {
return "style=\"background: red; color:#fff;\"";
}
else {
return "style=\"background: green; color:#fff;\"";
}
}
}
For output:
if (isset($_POST['submit'])) {
echo preTableFrmt();
foreach($engineer as $a => $b) {
echo "| [[$engineer[$a]]] || ".getCellColor('mon')." | $monday[$a] || ".getCellColor('tues')." | $tuesday[$a] || ".getCellColor('wed')." | $wednesday[$a] || ".getCellColor('thur')." | $thursday[$a] || ".getCellColor('fri')." | $friday[$a] || ".getCellColor('sat')." | $saturday[$a] || ".getCellColor('sun')." | $sunday[$a] <br />|-<br />";
}
echo postTableFrmt();
}
else { echo "Waiting for data..."; }
Note. When sending one line of the form, everything is in order; this is when I have more than one; then I get duplicate information.
The following example should show you what happens when I “add an engineer” (now doing two lines of lines). I will post the result after the image:
Application Image:

: , , , , . , , , , :
|-
| [[Drew Decker]] || style="background: yellow; color:#000;" | 7am7pmalt || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF || | || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF
|-
| [[Drew Decker]] || style="background: yellow; color:#000;" | 7pm-7am || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF || | || style="background: red; color:#fff;" | OFF || style="background: red; color:#fff;" | OFF
. style="background: yellow; color:#000;".
, , , . , , . , , , , , , , . , .
getCellColor() :
function getCellColor($index,$dow) {
if ( isset($_POST[$dow . 'shifthours'][$index]) && ($_POST[$dow . 'shifthours'][$index] == "7am7pmalt" || $_POST[$dow . 'shifthours'][$index] == "7pm7amalt")) {
return "style=\"background: yellow; color:#000;\"";
}
elseif ($_POST[$dow . 'shifthours'][$index] == "OFF") {
return "style=\"background: red; color:#fff;\"";
}
else {
return "style=\"background: green; color:#fff;\"";
}
}
My foreach :
foreach($engineer as $a => $b) {
echo "|-<br />| [[$engineer[$a]]] || ".getCellColor($a,"mon")." | ".format_date($monday[$a])." || ".getCellColor($a,"tues")." | ".format_date($tuesday[$a])." || ".getCellColor($a,"wed")." | ".format_date($wednesday[$a])." || ".getCellColor($a,"thur")." | ".format_date($thursday[$a])." || ".getCellColor($a,"fri")." | ".format_date($friday[$a])." || ".getCellColor($a,"sat")." | ".format_date($saturday[$a])." || ".getCellColor($a,"sun")." | ".format_date($sunday[$a])."<br />";
}
, , .