【发布时间】:2014-03-12 22:50:47
【问题描述】:
我想知道如果登录用户访问某个 URL,是否可以更新他的 MySQL 值。如果可能,最好的方法是什么?
例子:
MySQL,3 列:
用户名 id 计数
每次用户访问 count.php?ref=12 时,“count”值(如果是 10)应更改为 9。
【问题讨论】:
-
在你的页面头部(html 部分)包含更新mysql的代码。
标签: mysql url if-statement
我想知道如果登录用户访问某个 URL,是否可以更新他的 MySQL 值。如果可能,最好的方法是什么?
例子:
MySQL,3 列:
用户名 id 计数
每次用户访问 count.php?ref=12 时,“count”值(如果是 10)应更改为 9。
【问题讨论】:
标签: mysql url if-statement
我找到了以下解决方案,并且似乎可以正常工作:
$data = mysql_query("SELECT * FROM admin where username='$user_check' ")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
$status = $_GET['urlvalue'];
if($status == "0")
{
$sql = mysql_query("UPDATE admin SET count = (count - 1) where username='$user_check'");
}
【讨论】: