Ad Code

Check if value is the same in while loop

In general, to compare a row with the previous one, store the previous row's value in a variable. Make sure to assign the variable with a value that won't occur as a real value in your data.
$prevValue = NULL;
while(condition) {
 if ($curValue == $prevValue) {
  .
  . do stuff
  .
 }
 $prevValue = $curValue;
}

Post a Comment

0 Comments