title: PHP - edit multiple entries
body: <p>Given this form, shown as a table:</p>
  
  <pre><code>&lt;form action="multi.php" name="multi[]" method="POST" class="forms"&gt;
  &lt;table class="table-hovered"&gt;
   &lt;tr&gt;
    &lt;th class="text-left highlight"&gt;attività svolta&lt;/th&gt;
    &lt;th class="text-left highlight"&gt;categoria&lt;/th&gt;
   &lt;/tr&gt;
  &lt;?php
  foreach ($_POST['item'] as $k =&gt; $v)
  {
      $q_item = "SELECT * FROM eventi WHERE id = '".$v."'";
      $qu_item = mysql_query($q_item);
          while($res = mysql_fetch_array($qu_item))
          {
  ?&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;?php echo $res['descrizione'];?&gt;&lt;/td&gt;
    &lt;td&gt;
     &lt;select name="categoria"&gt;
      &lt;option value="&lt;?php echo $res['categoria'];?&gt;" selected&gt;&lt;?php echo $res['categoria'];?&gt;
      &lt;option value="80"&gt; 80
      &lt;option value="40"&gt; 40
      &lt;option value="70"&gt; 70
     &lt;/select&gt;
    &lt;/td&gt;
      &lt;input type="hidden" name="idd" value="&lt;?php echo $res['id'];?&gt;"&gt;
   &lt;/tr&gt;
  &lt;?php
          }
  }
  ?&gt;
  &lt;/table&gt;
  &lt;input type="submit" name="submit" value="modify" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am trying to edit multiple entries, using the code below:</p>
  
  <pre><code>&lt;?php
  $utente = $_SESSION["username"];
  $id = $_POST["idd"];
  $categoria = $_POST["categoria"];
  if (!$id or !$categoria){
  echo "Error";
  }
  else
   if ($categoria!=='80' &amp;&amp; $categoria!=='40' &amp;&amp; $categoria!=='70'){
   echo "Error";
  }
  else{
  $sql="UPDATE eventi SET categoria='$categoria' WHERE id='$id'";
  $update=mysql_query($sql);
  echo "Entry modified correctly";
  }
  ?&gt;
  </code></pre>
  
  <p>As you see, this code changes just one item. I have tried making it recursive. Maybe using a "foreach" is the way to go.</p>
  
  <p>Any hints are appreciated. And sorry for using an old version of PHP (I haven't switched to version 7 yet).</p>