{
............
............
$order_details="INSERT INTO .....";
mysql_query($order_details);
$o_id_detail[]=mysql_insert_id();
}
$prev_id=implode(',',$o_id_detail);
$last_id=explode(',',$prev_id);
foreach($last_id as $last)
{
$last;
foreach($addon_price as $a_p=>$p)
{
echo $a_p;
foreach($p as $m)
{
$addon_id= $m['id'];
echo $m['addon_name'];
echo $m['deposit'];
echo $m['ppd'];
echo $m['pp_eight'];
echo $m['pp_six'];
$addon_total = $m['deposit']+$m['ppd']+$m['pp_eight']+$m['pp_six'];
echo $addon_total;
$addon_detail="INSERT INTO tbl_orderdetail_addon
(OrderID,addOns_id,addOns_price)
VALUES ('$o_id_detail','$addon_id','$addon_total')";
if(!empty($addon_id)){
mysql_query($addon_detail)or die(mysql_error());
}
}
}
}
}
Now, Im getting ($last) inserted as many times as the foreach loops( foreach($addon_price as $a_p=>$p)).
How to restrict $last id form inserting any rows again if the ($last)id for a specific addon_item already exist?