Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The lunch and dinner code sections are using the same values for the <code>name</code> attributes. You need to give them different names altogether or append <code>[]</code> to create an array.</p> <p><strong>EDIT</strong>: For example, </p> <pre><code>echo '&lt;input type="checkbox" name="delete_'.$i.'[]" value="yes"&gt;&lt;/td&gt;'; </code></pre> <p>Notice the <code>[]</code> inside the double quotes for the value of the <code>name</code> attribute. You'd need to do this to all of them. I am not familiar with <code>DBUtils::arrayselect</code> so I am not if sure the following will work.</p> <pre><code>echo DBUtils::arrayselect($mealList, 'meal_id_'.$i.'[]', 'size=1', $meal); </code></pre> <p>But as long as you have more than one field with the same name, they will overwrite each other. With making these fields into arrays, you also need to change the code that processes the form so that it can process an array.</p> <p><strong>EDIT</strong>: You could also increment $i between the lunch and dinner sections instead of creating an array. Incrementing $i within the loop would require changing the <code>for</code> parameters, but at least you wouldn't have to change the code that processes the form.</p> <p>The <code>for</code> line seems very convoluted to me (and inefficient). A single line of code is not more efficient if it runs unnecessary calculations on each iteration of a loop. If I understand the intention correctly, try replacing the <code>for</code> line with the following.</p> <pre><code>$maxshow = 1; $num_items = isset($MPObj-&gt;mealplanItems[$dbDate]) ? count($MPObj-&gt;mealplanItems[$dbDate]) : 0; if ($num_items + $minshow &lt; $maxshow) $maxshow = $num_items + $minshow; $maxshow = $maxshow * 2; //double it because we will be incrementing $i within the loop for ($i = 0; $i &lt; $maxshow; $i++) { </code></pre> <p>And then add the following line between your original lunch and dinner sections (the ones without <code>[]</code>).</p> <pre><code>$i++; </code></pre> <p>That effectively assigns different names to each field without creating arrays.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload