I have the following code:
$q = "SELECT column_1, column_2, column_3, column_4 "
."FROM ".TBL_MYTBL." ORDER BY date DESC LIMIT 2";
$result = $database->query($q);
$num_rows = mysqli_num_rows($result);
if(!$result || ($num_rows < 0)) {
echo "Error displaying info";
return;
}
if($num_rows == 0) {
echo "Database table empty";
return;
}
If column1
from the last row is bigger than the same column from the second-to-last row, then I want to do action1
, otherwise action2
. How can I do that comparison?