我只想重置大于50的投票,目前重置每一个
<?
include('mysql_connect.php');
$query = "SELECT id, votes, callback FROM websites";
$result = mysql_query($query) OR die(mysql_error());
$query = "UPDATE websites SET votes = 0";
$result = mysql_query($query) OR die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
echo ('Database has been cleaned with a tissue.');
?>
我习惯编码Java所以我不确定我是否可以使用这个
$query = "UPDATE websites WHERE votes >= 50 SET votes = 0";
感谢您的帮助
答案 0 :(得分:3)
你关闭了。这样做。
$query = "UPDATE websites SET votes = 0 WHERE votes >= 50 ";
自PHP 5.5.0起,不再使用mysql_*
函数,将来也会删除它们。相反,应使用MySQLi
或PDO_MySQL
扩展名。
答案 1 :(得分:2)
您需要SET:
之后的WHERE语句$query = "UPDATE websites SET votes = 0 WHERE votes >= 50";