title: Update MySQL table with foreach passing multiple list values
body: <p>I'm actually running into an issue when trying to put this into practice. So, I have a list of goal ids and a current amount. I need to pass all these values which I am by doing goalidlist[] and current[]. The issue is when I'm running the foreach and doing the SQL Update per goalid. Here's my code below. Hope someone can point out what I'm doing wrong.</p>
  <pre><code>$goalidlist = $_POST['goalidlist'];
  $currentnums = $_POST['current'];
  if (isset($_POST['goalidlist'])) {
  
      foreach($goalidlist as $key =&gt; $glist) {
          
          // Update key goals
          $updGoals = &quot;UPDATE okr_3519031jkl.key_goals SET current=? WHERE goalid=? AND userid=?&quot;;
          
          if ($stmt = mysqli_prepare($conn, $updGoals)) {
              // Bind Params
              mysqli_stmt_bind_param($stmt, &quot;sii&quot;, $currentnums[$key], $glist, $userid);
              mysqli_stmt_execute($stmt);
              $stmt-&gt;close();
  
              
          }
      }
  }
  </code></pre>
  <p><strong>goalidlist[]</strong> = Array ( [0] =&gt; 4 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 3 [4] =&gt; 5 [5] =&gt; 6 [6] =&gt; 9 [7] =&gt; 7 [8] =&gt; 8 [9] =&gt; 10 [10] =&gt; 11 [11] =&gt; 12 [12] =&gt; 13 )</p>
  <p><strong>current[]</strong> = Array ( [0] =&gt; 3 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 6 [4] =&gt; 2 [5] =&gt; 12 [6] =&gt; 3 [7] =&gt; 1 [8] =&gt; 7 [9] =&gt; 9 [10] =&gt; 2 [11] =&gt; 6 [12] =&gt; 3 )</p>