[PHP] Hello again. new newbie querstion

2013-07-03 Thread Karl-Arne Gjersøyen
I have done as you explain for me an it works very vell in the halft part
of my application.
But below is my snippet of my source code where the number of items and
weight not will update itself.
This code do as what number I write in the oppdater_stk_nonel_tenner[]
field is written as result, instead of the calculated result.
I am also using var_dump() to check my viariables but there is something
here I have missed.

I hope it is ok to post my norwegian search code as an exaple. If this
source code is to difficult because of my long norwegian name (Description
of the meaning of varable) i will re-write it all in English as I appricate
your good advice and help!

Tanks.

// My form with array's
input type=hidden name=varenr[] value=?php echo $varenr; ?
input type=hidden name=stk_pa_lager[] value=?php echo
$stk_pa_lager; ?
input type=hidden name=kg_pa_lager[] value=?php echo
$kg_pa_lager; ?
input type=number name=oppdater_stk_nonel_tenner[] size=6
input type=hidden name=valgt_lager value=?php echo $valgt_lager;
?
input class=submitKnapp type=submit name=oppdater_nonel_tennere
value=Neste

if(isset($_POST['oppdater_nonel_tennere'])){
$valgt_lager = $_POST['valgt_lager'];
$varenr = $_POST['varenr'];
$kg_pa_lager = $_POST['kg_pa_lager'];
$stk_pa_lager = $_POST['stk_pa_lager'];
$oppdater_stk_nonel_tenner = $_POST['oppdater_stk_nonel_tenner'];

include('../../tilkobling.php');

// count how many serialnumber it is the the array for use later in for
loop.
$antall_varenr = count($varenr);

// Run for loop as long as $i is less than or equal to $antall_varenr.
for($i=0;$i$antall_varenr;$i++){

// update amont in stock. Adding value of
$oppdater_stk_nonel_tenner[$i] to $stk_pa_lager
$stk_pa_lager[$i] += $oppdater_stk_nonel_tenner[$i];

// Get new weight in kg in stock
$kg_pa_lager =  $stk_pa_lager[$i] * 0.001;

// Update the database table
$sql = UPDATE nonel_tennere SET stk_pa_lager = '$stk_pa_lager[$i]',
kg_pa_lager = '$kg_pa_lager' WHERE varenr = '$varenr[$i]' LIMIT 1;
mysql_query($sql,$tilkobling) or die(mysql_error());
var_dump($sql);
}
echo pstrongDatabasen er oppdatert/strong/p;
?
form action=index.php method=post
input type=hidden name=valgt_lager value=?php echo $valgt_lager;
?
input type=hidden name=admin_oppgave value=vis_status
input class=submitKnapp type=submit name=velg_lager value=Neste
/form



?php
}
?

I can't figure out why $stk_pa_lager[$i]; is the same as written in
$oppdater_stk_nonel_tennere[$i] as long I have us this += operator in

$stk_pa_lager[$i] += $oppdater_stk_nonel_tenner[$i];

I have just copy and past it from a working example above and chance the
table name and $oppdater_stk_nonel_tenner[$i] variable.

Thanks for your time.

Karl


Re: [PHP] Hello again

2012-07-02 Thread tamouse mailing lists
On Sun, Jul 1, 2012 at 6:21 PM, RGraph.net support supp...@rgraph.net wrote:
 Just thought I'd say hello again. Back to brush up on my PHP a little
 after a bit of a break - more reading than replying I'd imagine. I
 have some pretty bad jokes too that I might surreptitiously insert
 here and there...

Welcome back. Friday is mainly the free-for-all day (philosophical
questions, puns, jokes)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Hello again

2012-07-01 Thread RGraph.net support
Hi,

Just thought I'd say hello again. Back to brush up on my PHP a little
after a bit of a break - more reading than replying I'd imagine. I
have some pretty bad jokes too that I might surreptitiously insert
here and there...

Cheers.

-- 
Richard Heyes, RGraph.net support
RGraph: JavaScript charts for your website
http://www.rgraph.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php