30 and (NOW() - last_seen_mobile) < 3600"; $str = "select * from accounts where last_push_message_sent IS NOT NULL and (last_push_message_sent - last_seen_mobile) > 30 and (NOW() - last_seen_mobile) < 600"; $q = mysqli_query($link, $str); while($acc = mysqli_fetch_array($q)) { SendPush($acc['id'], "Check your SMoPP application!", 666); }