I am trying to delete a row from my wp_pagesvisites table.
global $wpdb;
$time = time();
$timebd = $wpdb->get_col("SELECT Timestamp FROM wp_pagesvisites");
foreach ($timebd as $v)
{
//echo ($time - $v)." - ";
if ($v - $time > 600)
{
$wpdb->query(
$wpdb->exec(
"DELETE FROM wp_pagesvisites WHERE Timestamp=$v"
)
);
}
}
It does enter my if condition because if I do an echo on $time – $v, some are greater than 600, so I think it’s my SQL query that is no good. Hopefully you can see my error.
you say ”
$time - $v, some are greater than 600″ but your if condition is vice versa (i.e.$v - $time)