Hmm remarkable things?

[email protected] (Karl-Arne Gjersøyen)
Newsgroups php.general
Message-ID <CAN78Z6DUFmQX8-wuemJjq+=2969WVfPbbJxEU2p9eCkURAUhHQ@mail.gmail.com>
Hello again.
Thanks for last answere. It works very well but now I have another
remarkable things. Perhaps logic but not for me yet..

I have this source code: (In norwegian but I translate my thoughts through
it in english.)

The problem with this source code is that it work very well if I select one
single item and post it. But when select 2 or more items the same amount
are filled in all field named stk_pa_lager in the database.

// count and increase the amount of tubes.
if(isset($_POST['oppdater_antall_stk_rorladning'])){

// Get store
    $valgt_lager = $_POST['valgt_lager'];

// Get serial number   (Array <input type="number" name="varenr[] size="3">)
  $varenr = $_POST['varenr'];

// number of items in store
    $stk_pa_lager = $_POST['stk_pa_lager'];

// Create an array (<input type="number"
name="oppdater_antall_stk_rorladning[] size="3">)
    $oppdater_antall_stk_rorladning =
$_POST['oppdater_antall_stk_rorladning'];

// Extract the array and save it induvidual as items in $rorladning
    foreach($oppdater_antall_stk_rorladning as $rorladning){

// Multiply and add new items to that one already is in store
        $oppdatert_antall_stk_rorladning = $stk_pa_lager + $rorladning;

// Extract serialnumber and save them one by one in $vnr
    foreach($varenr as $vnr){

// Connect to MySQL database
    include('../../tilkobling.php');

// Update table rorladning
    $sql = "UPDATE rorladning SET stk_pa_lager =
'$oppdatert_antall_stk_rorladning' WHERE valgt_lager = '$valgt_lager' AND
varenr = '$vnr'";
    mysql_query($sql, $tilkobling) or die(mysql_error());

        }

// Output the result to screen
        echo "<p>R&oslash;rladning med varenr: <b>$vnr</b> er oppdatert fra
<b>$stk_pa_lager</b> til <b>$oppdatert_antall_stk_rorladning</b> p&aring;
lager: <b>$valgt_lager</b>.</p>";
        //echo "$oppdatert_antall_stk_rorladning<br>";
    unset($rorladning);
    unset($vnr);
    }
}


// My database table:
mysql> SELECT * FROM rorladning;
+------------+-------------+-------+-------------+--------------+---------+--------------+-------------+
| leverandor | valgt_lager | un_nr | varenavn    | varenr       | dim_mm  |
stk_pa_lager | kg_pa_lager |
+------------+-------------+-------+-------------+--------------+---------+--------------+-------------+
| Orica      | Tengs       | 0081  | Hvit Rør   | ETX1.22X1000 | 22x1000 |
70           | 3.7         |
| Orica      | Tengs       | 0081  | Orange Rør | ETX1.17X460  | 17x460  |
70           | 0.95        |
+------------+-------------+-------+-------------+--------------+---------+--------------+-------------+
2 rows in set (0.00 sec)

mysql>

What I think i am doing wrong is the way I write the php/mysql stuff. What
I want is to store differt values in stk_pa_lager based on the particular
serialnumber. (field varenr).

I will be very thankful if you can tell me what is wrong here and point out
what to do with it.
Thanks for your time.

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.