表结构: 用户名|密码电邮|帖子 我目前正在使用以下信息显示他们的帖子数: $ sql = mysql_query("SELECT`posts from`user` WHERE username ='$ username'")或die(mysql_error());$ row = mysql_fetch_array($ sql);回声< br/>< h4>您的帖子:</h4>".".$ row ['posts']; 已解决:我接受了Marc提出的使用模数的建议,该模数适合我的需求. $ sql = mysql_query("SELECT`posts` AS post from`user` WHERE username ='$ username'")或die(mysql_error());$ row = mysql_fetch_array($ sql);$ post = $ row ['posts'];if($ post%100 == 0){mysql_query("INSERT INTO`posts(name,message,message_raw)VALUES('System','$ name has been $ post posts!','$ name has been $ post posts!')");} 解决方案您需要取模 模运算.返回N除以M的余数.赞 SELECT用户名来自`user`其中username ='$ username'AND MOD(posts,100)= 0 您可以在用户每次发表新帖子时检查情况I need to alert members of a site when their post count has reached a multiple of 100. Is it possible to run a function or echo something when a value in a mysql table reaches 100, 200, 300, etc?Table structure:username | password | email | postsI'm currently displaying their post count with:$sql = mysql_query("SELECT `posts` FROM `user` WHERE username='$username'") or die(mysql_error());$row = mysql_fetch_array($sql);echo "<br /><h4>Your posts:</h4>" . " " . $row['posts'];RESOLVED: I went with Marc's suggestion of using modulo, which suited my needs.$sql = mysql_query("SELECT `posts` AS posts FROM `user` WHERE username='$username'") or die(mysql_error());$row = mysql_fetch_array($sql);$post = $row['posts']; if($post % 100 == 0) { mysql_query("INSERT INTO `posts` (name, message, message_raw) VALUES ('System', '$name has reached $post posts!', '$name has reached $post posts!')"); } 解决方案 You need a modulo Modulo operation. Returns the remainder of N divided by M.Like thisSELECT usernameFROM `user`WHERE username='$username' AND MOD(posts,100) = 0And you can check the condition every time a user do a new post 这篇关于MYSQL列值增加100时执行某些操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-05 14:10