I want insert some rows into mysql, each row shold be like this:
<input name="code[]" value="{code item dari data mysql}" />
<input name="name[]" value="{nama dari data mysql}" />
<input name="hrg[]" value="{harga dr mysql}" />
<input name="qty[]" value="{qty diinput sendiri}" />
<input name="subt[]" value="{autocalculated saat mengisi qty}" />
The processor:
<?php //if i press submit on form, then:
for($i=0;$i<count($qty);$i++)
{
$query="INSERT INTO transaksi VALUES(NULL, '$code[$i]', '$name[$i]' , '$price[$i]' , '$qty[$i]' , '$subt[$i]') ";
mysql_query($query);
} ?>
But it produces bad results:
The datas inserted beeing like these:
id | code | name | price | qty | subt
1, 'A','A',100,2,200
2, 'R','R',100,2,200
3, 'R','R',100,2,200
4, 'A','A',100,2,200
5, 'Y','Y',100,2,200
$code and $nama variables all contains data: "ARRAY", so it read them as $code[0] = "A", $code[1]="R" etc.
what's wrong with my code?
plz help me.