one row insert into mysql from a loop php
I have a loop where I need to get the elements and then I need to insert
each element in mysql table but this code is able to insert only 1
element.(p.s. The variable is loaded with min 4 element).
Why I'm not able to insert multiple element with this loop?
Please I need it to know urgently.Thanks
function addmijloc(){
foreach ($_SESSION["mijloc"] as $check)
{
$sql="INSERT INTO isu_mijloace (`nr_rap_ext_mijl`, `mijloc`) VALUES
('".$_SESSION['nrraport']."', '".$check."')";
if(mysql_query($sql))
{
$mijloace="ok";
}
else
{
echo '<script>alert("Tabela mijloace eronata");</script>';
}
}
}
No comments:
Post a Comment