update multiple rows in table mysql
<p>im wondering if someone could point me in the right direction as im trying to update multiple rows but for some reason everytime time i do the update, variable id_employee is set with the same value for all the rows.. that´s what i figured out when i var_dumped $_POST. The rest of fields are fine.. Here is a complete view of my code. <a href="http://pastie.org/5478920" rel="nofollow">http://pastie.org/5478920</a>, also this is what i get when i var_dump <a href="http://pastie.org/5478980" rel="nofollow">http://pastie.org/5478980</a></p>

<pre><code>    $query = "update project_staff
    set
    id_employee=?
    where
    id_project=?
    and
    id_projectemployee=?
    ";

    $stmt = $this-&gt;dbh-&gt;prepare($query);

    for ($i = 0; $i &lt; count($_POST['id_employee']); $i++){

    $employee = $_POST['id_employee'][$i];

    $stmt-&gt;bindValue(1, $employee, PDO::PARAM_INT);
    $stmt-&gt;bindValue(2, $_POST["id"], PDO::PARAM_INT);
    $stmt-&gt;bindValue(3, $_POST["idstaff"], PDO::PARAM_INT);

    $stmt-&gt;execute();

    }

    echo("Project" . " " . $_POST["nom"] . " ". "has been updated");
</code></pre>
