开发者

PHP MySQL Tables Assistance

开发者 https://www.devze.com 2023-04-12 10:42 出处:网络
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?

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=\"backgro开发者_开发知识库und-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>");


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号