hii ppl..
i have a edit form, which is populated from the database, things work fine till here. now i want to update the table with editted details. if i echo the details from $_POST variables it prints fine. but if i update the table it doesnt..
this form is generated dynamically, hence there are multiple rows to be edited. when update is clicked all the rows are updated with the details of one particular row and not with their respective details.
pls have a look at the code..n save my day...
foreach($_POST['quantity'] as $temp)//this data comes from text field
{
$quantity[]=$temp;
}
foreach($_POST['rate'] as $temp)//this data comes from text field
{
$rate[]=$temp;
}
foreach($_POST['total'] as $temp)//this data comes from text field
{
$total[]=$temp;
}
foreach($_POST['component'] as $item)//this data comes from dropdown
{
$sqlI="select id from component_item where name='".$item."'";
$resI=mysql_query($sqlI);
$rowI=mysql_fetch_array($resI);
$itemId[]=$rowI['id'];
}
/*for($i=0;$i<count($quantity);$i++)//lets say $quantity=3 i.e there are 3 rows of input field populated from db, it prints fine here
{
echo $quantity[$i]."<br>";
echo $rate[$i]."<br>";
echo $total[$i]."<br>";
echo $itemId[$i]."<br>";
}*/
for($i=0;$i<count($quantity);$i++)
{
$query="update purchase_order_detail set component_item_id='$itemId[$i]', quantity='$quantity[$i]', rate='$rate[$i]', total='$total[$i]' where purchase_order_id='$id'";
$result=mysql_query($query) or die(mysql_error());
}
please let me know if u find something wrong in my code..cos i get no error for the query..
but all 3 rows are updated with data of one particular row as if, $i is not incrementing..
thanks ppl..