I have the following set of if/elseif conditions that update columns titled Col
& Col2
when a form is submitted:
if($data3["Col"] < 2 ){
$db->query("UPDATE answers SET Col = Col+1");
}elseif( $data3["Col"]= 2){
$db->query("UPDATE answers SET Col = Col+0");
}
if($data3["Col2"] < 10){
$db->query("UPDATE answers SET Col2 = Col2+1");
}elseif( $data3["Col2"] >= 10){
$db->query("UPDATE answers SET Col2 = Col2+0");
}
When the code runs, it ignores the if/elseif conditions and does every update. For example, let's say upon form submit, Col = 2
& Col2 = 10
. Col
and Col2
should both stay stay the same. However, the code updates both by 1. I've tried every iteration that I can think of using continue
, break
, and return
but nothing seems to work.
Any help would be much appreciated.
Thanks!