Var_Dump与mt_rand

时间:2017-01-27 23:50:29

标签: php mysql

以下声明未返回任何结果。我检查了SQL语句,它们是正确的,似乎没有编码错误。

<?php

require_once "func.php";
require_once "websockets.php";

//  private $curResultId;
//  private $MaxResult;
//  private $MinResult;

for( $i = 0; $i<5; $i++ ) {
    $row = db_fetch_item("SELECT resultid FROM ResultPackage 
        where ResultPackage.slotid like '1'
        and ResultPackage.PackageID like '1'
        ORDER BY resultid desc LIMIT 1");
    $this->MaxResult = $row['resultid'];


    $row = db_fetch_item("SELECT resultid FROM ResultPackage 
        where ResultPackage.slotid like '1'
        and ResultPackage.PackageID like '1'
        ORDER BY resultid asc LIMIT 1");
    $this->MinResult = $row['resultid'];

    $this->curResultId = mt_rand($this->MinResult,$this->MaxResult);


        var_dump($this->curResultId);


    }

?>

请帮忙

1 个答案:

答案 0 :(得分:0)

什么是$this?这是类方法的一部分还是你的所有脚本?如果它不是类,则应使用其他变量而不是$this

for($i=0; $i<5; $i++) {
    $row = db_fetch_item("SELECT resultid FROM ResultPackage 
        where ResultPackage.slotid like '1'
        and ResultPackage.PackageID like '1'
        ORDER BY resultid desc LIMIT 1");
    $MaxResult = $row['resultid'];

    $row = db_fetch_item("SELECT resultid FROM ResultPackage 
        where ResultPackage.slotid like '1'
        and ResultPackage.PackageID like '1'
        ORDER BY resultid asc LIMIT 1");
    $MinResult = $row['resultid'];

    $curResultId = mt_rand($MinResult,$MaxResult);

    var_dump($curResultId);
}
相关问题