循环数据它永远不会显示第一行

时间:2018-06-05 16:57:52

标签: arrays database loops

我有这个代码,它应该从数据库中的表中给我一系列数据。例如,我知道该表有" CPT"记录从1到10,但当我循环通过它给我记录3到6它只给我记录4到6.或记录2到8它跳过2并给我3到8.它总是跳过我问的第一个记录在该范围内,它不显示。我错过了什么吗? 在此先感谢您的帮助。

    $fee_sql = "SELECT CPT AS CPT, Fee_Allow, Fac_Allow FROM PPN_PhysiciansFeeSchedule WHERE LTRIM(RTRIM(`CPT`)) >= '" . $cptCodeLower . "' AND LTRIM(RTRIM(`CPT`)) <= '" . $cptCodeUpper . "' AND Contract_ID = '".$col["Contract_ID"]."'ORDER BY 'CPT' DESC LIMIT " . $page_start . ", " . $page_end;


    $fees = $conn->query($fee_sql);
    while($row = $fees->fetch_assoc()) {
        if(!in_array($row["CPT"], $row_list, true))
            array_push($row_list, $row["CPT"]);

        $schedule_list[$col["Contract_ID"]][$row["CPT"]] = $row[$fee_type];
    }

}

$data["col_list"] = $col_list;
$data["row_list"] = $row_list;
$data["results"] = $schedule_list;

header('Content-Type: text/json');

try {
    echo json_encode($data);
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage();
}

0 个答案:

没有答案