} } else $count++; if($count == 9){ $keys = $wpdb->get_results("SELECT * FROM all_keys WHERE user_got IS NULL AND deal_name = '".substr(substr(get_permalink(), 17), 0, -1)."' ORDER BY id ASC LIMIT 1"); if($keys[0]->id){ $keys = $wpdb->get_results("UPDATE all_keys SET user_got = '".get_user_meta(get_current_user_id(), 'steam_steamid', true)."', got = CURRENT_TIMESTAMP WHERE user_got IS NULL AND id = '".$keys[0]->id."'"); echo "All tasks are done. To get the key, refresh the page."; } else echo "We're sorry, but there's no more keys
Wait for new distributions
"; } else echo "
After making all the tasks refresh the page.
"; $keys_num = $wpdb->get_var("SELECT COUNT(*) FROM all_keys WHERE deal_name = '".substr(substr(get_permalink(), 17), 0, -1)."' AND user_got IS NULL"); if($keys_num[0]) echo "
Keys left: {$keys_num}"; } else echo "We're sorry, but there's no more keys
Wait for new distributions
"; } } } else echo "