English 中文(简体)
PHP/MySQL 书记赢得了笔记,让用户在排定的时间内访问不止一次。
原标题:PHP/MySQL script won t let user visit more than once in an alotted time
  • 时间:2012-01-11 11:38:49
  •  标签:
  • php
  • mysql

I am trying to write a script for a game I m working on that only rewards a user s click on a specific link once each day.

我认为,最好的方式是,在用户历史的奖励表格中提供一个领域,使用户名和时间与他们获得奖励的时间相挂钩。

因此,每当点击该链接时,这些数值必须从最后24小时起与所有其他数值一起储存在外地“历史”中:

$username = GET[ username ];
$time = time();

在一个领域、多个层面阵列中,如何保存多种价值观? 我如何储存这些物品,然后再收回这些物品?

在我了解如何收回这些数值后,我就认为,利用预想(match)寻找用户名称的重复。 如果遣返真的,则检查时间(......);如果时间超过24小时,更新时间(......);对现在和奖励,否则如果不超过24小时,则不给他们新的报酬(如果是假的),他们就会得到回报。

任何想法?

EDIT:Alright,如果将价值观引入一个领域,那是不是最佳方式? 每天增加许多奖励(100 s),而且很快就到期,因此,在用户信息表内为每一项奖励提供一个场所肯定不会是最佳的方式? 这将意味着每增加一次新的奖励,必须把一个新的领域列入用户目录......。 然后,如果奖励到期,就必须删除所有这些栏目。 你们所说的话吗?

问题回答

为什么所有有多层次阵列和管制的行业? 页: 1

每一奖章

| user_id | last_rewarded_at |
|   42    |     2011-01-11   |

这样,你就可以轻率地增加新的奖励,如果用户在某一天获得奖励,就进行检查。

“在一个领域储存多种价值的最佳途径”的答案是DO NOT DO DO IT。

一个领域——一个价值,它很容易。

如果ReALLY认为有必要忽略这些答复,STILL储存一个领域的所有数据(贫穷做法)——然后利用json-encode在某个领域储存多维数据,将其储存起来,json_decode将其改成物体

<?php
$stored = json_encode($array_data);

$read = json_decode($stored);
?>

铭记json的编码数据将编码为UBJECT,而不是ARRAY,以便用于:

$read = (array) json_decode($stored);

你们会遇到这样的业绩问题。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签