hi frens..
i am working on a project, where, i had to add rows to table dynamically on click of button. i got to work that part, but got stuck with getting to save the data entered into db. i have not missed to add "[]" to the names in input tag. i have posted the code below, its working partially. lets say user enters 2 rows of data, $itemId and $poId are getting saved properly, but for quantity, rate and total only one row of data is getting saved, where am i going wrong, can anyone pls point out??
i have spent last 10 hours on this phew:sad:
also, is the method i am using correct, is there any other better/efficient method to do the same??
$component = $_POST['component'];
$quantity[] = $_POST['quantity'];
$rate[] = $_POST['rate'];
$total[] = $_POST['total'];
$i=0;
foreach($_POST['component'] as $item)
{
$sqlI="select * from component_item where name='".$item."'";
$resI=mysql_query($sqlI);
$rowI=mysql_fetch_array($resI);
$itemId[]=$rowI['id'];
}
foreach($_POST['quantity'] as $temp)
{
$quantity[]=$temp;
}
foreach($_POST['rate'] as $temp)
{
$rate[]=$temp;
}
foreach($_POST['total'] as $temp)
{
$total[]=$temp;
}
for($i=0;$i<count($itemId);$i++)
{
$query="insert into purchase_order_detail values('','$itemId[$i]','$quantity[$i]','$rate[$i]','$total[$i]','$poId')";
$result=mysql_query($query);
}
thanks ppl...