Foreach and mydql_query problem

[email protected] (Karl-Arne Gjersøyen)
Newsgroups php.general
Message-ID <CAN78Z6Dka2T7N3n7+56NcpRREY+CqgNY6c=xukpPsKdMeYEwaw@mail.gmail.com>
Hello again.
I have this this source code that not work as I want...

THe PHP/HTHML form fields is generated by a while loop and looks like this:

<input type="number" name="number_of_items[]" size="6" value="<?hp
echo "$item"; ?>" required="required">


the php source code look like this:
<?php
if(!empty($_POST['number_of_itemsi'])){
    include('../../connect.php');

        foreach($number_of_items as $itemi){
        echo "$itemi<br>";

            $sql = "UPDATE item_table SET number_item = '$item' WHERE date
= '$todays_date' AND sign = '$username'";
            mysql_query($sql,$connect) or die(mysql_error());
     }
}

?>

The problem is:
Foreach list every items as expected in PHP doc and I thought that $sql and
mysql_query should be run five times when I have five items.
But the problem is that only the very last number_of_items is written when
update the form..
I believe this is becayse number_of_items = '$item in $sqk override every
earlier result.

So my querstion is. How to to update the database in this case?

Thanks again for your good advice  and time to help me.

Karl'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.