为什么我看到资源ID #Number消息?

时间:2013-12-19 15:53:59

标签: php mysql foreach

在我的页面上列出的每条记录中,始终有资源ID#5,就像数字一样。

这是我的sql:

$sorusayisi = 57;
for ($i = 1; $i < $sorusayisi; $i++) {
    // $soruId = array();
    $soruQues = array();
    $soruCevapId = array();

    if (strlen($levonter) == 0) {
        $sqlSorular = mysql_query("SELECT * FROM tblquestions AS r1 JOIN (SELECT (RAND() * (SELECT MAX(id) FROM tblquestions)) AS id) AS r2 WHERE r1.Id >= r2.Id AND r1.GroupId");
    }
    else {
        $sqllevonter = substr($levonter, 0, -1);
        echo $sqlSorular = mysql_query("SELECT * FROM tblquestions AS r1 JOIN (SELECT (RAND() * (SELECT MAX(id) FROM tblquestions)) AS id) AS r2 WHERE r1.Id >= r2.Id AND r1.GroupId NOT IN ($sqllevonter)");
    }

    $bisey = mysql_fetch_array($sqlSorular);
    while ($rsSorular = mysql_fetch_array($sqlSorular)) {
        $soruCevapId[] = $rsSorular["Id"];
        $soruQues[] = $rsSorular["Question"];
        $soruGrId = intval($rsSorular["GroupId"]);
    }

    $soruGrId = intval($bisey["GroupId"]);
    $levonter .= $soruGrId . ',';

    $sHint = mysql_query("SELECT * FROM tblhints WHERE GroupId=" . $soruGrId . "");
    $rsHint = mysql_fetch_array($sHint);
    $soruHint = $rsHint["hint"];
    $soruPic = $rsHint["pic"];

    $sCevap = mysql_query("SELECT * FROM tblanswers WHERE GroupId=" . $soruGrId . "");
    $rsCevap = mysql_fetch_array($sCevap);
    $cevapId = $rsCevap["Answer"];
    // $soruPic = $rsCevap["pic"];

我看不到任何感觉?

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

$sqlSorular是从mysql_query返回的资源,您echo正在使用它:

echo $sqlSorular=mysql_query("SELECT * FROM tblquestions AS r1 JOIN (SELECT (RAND() * (SELECT MAX(id) FROM tblquestions)) AS id) AS r2 WHERE r1.Id >= r2.Id AND r1.GroupId NOT IN ($sqllevonter)");