我怎樣才能讓PHP刪除限制用戶每月刪除用戶搜索限制:: MYSQL
我有這樣的代碼來增加一個用戶的搜索限制,如果他們達到其極限
$search = $db->prepare("SELECT `searched` FROM `search` WHERE `user_id` =:user_id");
$search->bindValue(':user_id', $vbulletin->userinfo['userid'], PDO::PARAM_INT);
$search->execute();
$result = $search->fetch(PDO::FETCH_ASSOC);
if ($result['searched'] >= 100){
exit('You have reached your search limit for this month.<br>');
}
$addsearch = $db->prepare("UPDATE `evomap`.`search` SET `searched` = :searched + 1 WHERE `search`.`id` =:user_id;");
$addsearch->bindValue(':user_id', $vbulletin->userinfo['userid'], PDO::PARAM_INT);
$addsearch->bindValue(':searched', $result['searched'], PDO::PARAM_STR);
$addsearch->execute();
/* page i want to execute if user has no reached limit */
您是否需要存儲用戶搜索了多少?你可以每月一次截斷表格。 – Duniyadnd 2013-03-11 00:20:25