簡體   English   中英

帶有jtable帖子的未定義索引

[英]Undefined index with jtable post

表負載

$('#searchVehicleDesc').button().click(function (e) {
    e.preventDefault();
    $('#vehicleLogsTable').jtable('load', {
        plate: $('input[name=vehicle_service_search]').val(),
        date1: $('input[name=searchDate1]').val(),
        date2: $('input[name=searchDate2]').val()
    });

PHP

<?PHP
include("db.classes.php");
$g = new DB();
$g->connection();

        $term ="";
        $d1 ="";
        $d2 = "";

        if(isset($_POST['plate']) && isset($_POST['date1']) && isset($_POST['date2']))
        {
            $term = $_POST["plate"];
            $da1 = $_POST["date1"];
            $da2 = $_POST["date2"];
            $g->getAllDesc($term, $da1, $da2);
        }

        else
        {
// line 20      $term = $_POST["plate"];
// line 21      $d1 = $_POST["date1"];
// line 22      $d2 = $_POST["date2"];
            $g->getAllDesc($term, $d1, $d2);
        }   

$g->close();
?>

我需要傳遞這三個數據來查詢它,但是我在第20、21、22行中收到了未定義的索引錯誤,這里似乎有什么問題?

嘗試先檢查一下

$term = isset($_POST["plate"]) && !empty($_POST["plate"]) ? $_POST["plate"] : null;

現在,如果帖子中沒有這些字段,您就不會遇到錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM