Good Day all
I am working on a small php project where I send a comma delimated string to my php script. The issue I am having is, I am trying to get the script to execute 5 times and the 5 values be inserted but so far I see to be doing something wrong and only the final value gets inserted.
I have changed the value of $variable to see if the issue was with the string i was using but there is still no change. Grateful for any assistance as i have placed my code below.
$variable = 'value1, value2, value3, value4, value5';
$arrs = explode(',', $variable);
foreach($arrs as $arr){
$sql = "INSERT INTO diver(refno,f_name,l_name,sig) VALUES ('$refno','$f_name','$variable',',')";
}
if(mysqli_query($conn,$sql)){
echo "Works ";
}else{
echo("Error description: " . mysqli_error($conn));
}
}else{
echo("Error description: " . mysqli_error($conn));
}