PHP MySQL 表帮助
我有一个脚本,我在页面上稍微编辑了一下,它没有显示 7 天的统计数据,这可能是什么原因造成的?
这是页面的部分代码 (顺便说一句,我尝试恢复备份,但没有任何更改,所以它一定是来自其他地方)
echo("</td><td>");
@mysql_free_result($res);
$i = 0;
$res = @mysql_query("select date from 7stat where usrid=$usrid order by date desc limit $keep_stats");
$darr = array();
for ($i = 0; $i < @mysql_num_rows($res); $i++) {
$darr[] = @mysql_result($res, $i);
}
$mvcx = $keep_stats-1;
@mysql_free_result($res);
$i = 0;
if (mysql_query("select count(*) from 7stat where usrid=$usrid") > $keep_stats) {
@mysql_query("delete from 7stat where usrid=$usrid && date < $darr[$mvcx]");
}
$darr2 = array();
reset($darr);
while (list($k, $v) = each($darr)) {
$res = @mysql_query("select num from 7stat where date='$v' && usrid=$usrid");
$darr2[$v] = @mysql_result($res, 0);
@mysql_free_result($res);
}
$maxnum = 0;
reset($darr2);
while (list($k, $v) = each($darr2)) {
$maxnum = $maxnum + $v;
}
$maxnum = round($maxnum);
echo("\n<b>Surf Credits Earned Last $keep_stats Days:</b><br><table border=0 cellpadding=2>");
reset($darr2);
while (list($k, $v) = each($darr2)) {
$v = round($v, 2);
$px = 500 * ((($v * 100) / $maxnum) / 100);
$px = round($px);
echo("\n<tr><td style=\"background-color: #4DA0C6\"><font color=\"#FFFFFF\"><b> $k </b></font></td><td align=left> - <b>$v credits</b></td></tr>");
}
echo("</table>");
echo("</td></tr></table>");
I have a script which I edited a little bit, on a page, it doesn't show the 7 day stats, what could cause this?
Here is a partial code of the page
(By the way I tried restoring backup, and no changes at all so it must be from somewhere else)
echo("</td><td>");
@mysql_free_result($res);
$i = 0;
$res = @mysql_query("select date from 7stat where usrid=$usrid order by date desc limit $keep_stats");
$darr = array();
for ($i = 0; $i < @mysql_num_rows($res); $i++) {
$darr[] = @mysql_result($res, $i);
}
$mvcx = $keep_stats-1;
@mysql_free_result($res);
$i = 0;
if (mysql_query("select count(*) from 7stat where usrid=$usrid") > $keep_stats) {
@mysql_query("delete from 7stat where usrid=$usrid && date < $darr[$mvcx]");
}
$darr2 = array();
reset($darr);
while (list($k, $v) = each($darr)) {
$res = @mysql_query("select num from 7stat where date='$v' && usrid=$usrid");
$darr2[$v] = @mysql_result($res, 0);
@mysql_free_result($res);
}
$maxnum = 0;
reset($darr2);
while (list($k, $v) = each($darr2)) {
$maxnum = $maxnum + $v;
}
$maxnum = round($maxnum);
echo("\n<b>Surf Credits Earned Last $keep_stats Days:</b><br><table border=0 cellpadding=2>");
reset($darr2);
while (list($k, $v) = each($darr2)) {
$v = round($v, 2);
$px = 500 * ((($v * 100) / $maxnum) / 100);
$px = round($px);
echo("\n<tr><td style=\"background-color: #4DA0C6\"><font color=\"#FFFFFF\"><b> $k </b></font></td><td align=left> - <b>$v credits</b></td></tr>");
}
echo("</table>");
echo("</td></tr></table>");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
“最近 0 天收到的冲浪点击数:以及最近 0 天获得的冲浪积分:”
行是在$keep_stats
变量的帮助下构建的。如果此变量的值为0
(如前面的字符串所示),您的 SQL 查询将包含行LIMIT 0
,这将禁止 MySQL 返回任何行。您的解决方案在于找出
$keep_stats
的设置位置以及为什么将其设置为0
。我也不确定这
是什么意思。
mysql_query
将返回一个Resource
,您必须使用mysql_result
或其他此类函数来解析它才能使用。Your
"Surf Hits Received Last 0 Days: and Surf Credits Earned Last 0 Days:"
line is build with the help of the$keep_stats
variable. If the value of this variable is0
, as evidenced in the previous string, your SQL query will include the lineLIMIT 0
, which will suppress MySQL from returning any rows.Your solution lies in finding out where
$keep_stats
is set and why it's set to0
.I'm also not sure what
is supposed to mean.
mysql_query
will return aResource
, which you'll have to parse withmysql_result
or another such function to use.