我有这个查询:
$result2 = mysql_query("SET @total=0;
SELECT *,
@total:= @total+ `companyearned` AS `total`
FROM `recordedhours` WHERE `group` = '$uid'
ORDER BY `unixdate` DESC, `idnum` DESC
LIMIT $from, $max_results");
while ($rowb = mysql_fetch_array($result2)) {
//DO STUFF
}
但是 SET @total=0; 使while行给我一个错误:警告:mysql_fetch_array():提供的参数不是有效的MySQL结果资源查询在phpmyadmin中工作正常,而没有SET @total = 0的while工作正常;