PHP MySQL 表帮助

发布于 2024-12-09 09:21:58 字数 1584 浏览 0 评论 0原文

我有一个脚本,我在页面上稍微编辑了一下,它没有显示 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>&nbsp; $k &nbsp;</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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒尘 2024-12-16 09:21:58

您的 “最近 0 天收到的冲浪点击数:以及最近 0 天获得的冲浪积分:” 行是在 $keep_stats 变量的帮助下构建的。如果此变量的值为 0(如前面的字符串所示),您的 SQL 查询将包含行 LIMIT 0,这将禁止 MySQL 返回任何行。

您的解决方案在于找出 $keep_stats 的设置位置以及为什么将其设置为 0

我也不确定这

 if (mysql_query("select count(*) from 7stat where usrid=$usrid") > $keep_stats)

是什么意思。 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 is 0, as evidenced in the previous string, your SQL query will include the line LIMIT 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 to 0.

I'm also not sure what

 if (mysql_query("select count(*) from 7stat where usrid=$usrid") > $keep_stats)

is supposed to mean. mysql_query will return a Resource, which you'll have to parse with mysql_result or another such function to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文