显示未定义的index..edit值未插入数据库

时间:2015-09-01 05:46:01

标签: ajax yii2 yii2-advanced-app

  

我正在使用yii2,我需要将编辑值插入数据库并进行编辑   列由ajax创建。 php列插入中的值   正确地...提前谢谢

if(isset($hotelInsertId)){
            $noOfSeason = $_POST['numOfSeason'];
    $seasonRow  = 1;


            for($i=0;$i<$noOfSeason;$i++){ // strt season loop


                $from_date_season = $_POST['season_from_date'.($seasonRow-1)];
                $to_date_season = $_POST['season_to_date'.($seasonRow-1)];

                $from_date  = date('m/d/Y',strtotime($from_date_season));
                $to_date    = date('m/d/Y',strtotime($to_date_season));


                $year1= date('Y',strtotime($from_date_season));
                $year2= date('Y',strtotime($to_date_season));

                $day = date('d',strtotime($from_date_season));
                $month = date('m',strtotime($from_date_season));

                $from_date_unix = strtotime($from_date);
                $to_date_unix   = strtotime($to_date);

                $datediff =$to_date_unix - $from_date_unix;
                //echo $datediff;

                $no_of_days = floor($datediff / 86400);

                //$seasonIds=$seasonArray[$seasonRow-1];
                $seasonIds  = 0;

                if(($i+1)%$roomCatNo!=0){
                    $seasonRow++;
                }
                else{
                    $seasonRow++;
                }


                $from_date_a    = explode('-',$from_date);

                $to_date_a      = explode('-',$to_date);

                if($from_date_unix < $to_date_unix) {

                    if($to_date_a[0] >= $from_date_a[0]) {

                        for($j=0;$j<$roomCatNo;$j++){

                            if(( (0 == $year1 % 4) and (0 != $year1 % 100) or (0 == $year1% 400))||((0 == $year2 % 4) and (0 != $year2 % 100) or (0 == $year2 % 400))) {
                                $no_of_days_leap = $no_of_days + 2;

                            }
                            else{
                                $no_of_days_leap = $no_of_days + 1;

                            }



                            for ($k=0;$k<$no_of_days_leap;$k++) {


                            $roomType1      = $_POST['int_no_of_room'.$i.$j];

                            $roomNo1        = $_POST['int_roomNo'.$i.$j];
                            $personNo1      = $_POST['int_personRoom'.$i.$j];
                            /*$rakRatePkg1  = $_POST['float_rackRatePackage'.$i.$j];*/
                            $spRatePkg1     = $_POST['float_specialRatePackage'.$i.$j];
                            $rkRateHtl1     = $_POST['float_rackRateHotel'.$i.$j];
                            $spcRatehtl1    = $_POST['float_specialRateHotel'.$i.$j];

                            $modelHotelRateId = $_POST['int_rateId'.$i];
                            $modelHotelRate = new \common\models\TblHotelRate;
                            $modelHotelRate->isNewRecord = true;
                            //$modelHotelRate->primaryKey = NULL;
                            $modelHotelRate->int_hotelId = $hotelInsertId;
                            $modelHotelRate->season_from_date = $from_date_unix;
                            $modelHotelRate->season_to_date = $to_date_unix;
                                $modelHotelRate->season_days = strtotime($from_date. ' + ' .$k. 'day');

                                $modelHotelRate->int_season_id = $noOfSeason;
                            //$modelHotelRate->s_fd_md = $s_fd_md;
                            //$modelHotelRate->s_td_md = $s_td_md;
                            $modelHotelRate->no_of_days = $no_of_days;
                            $modelHotelRate->int_roomCatId = $roomType1;
                            $modelHotelRate->int_roomNo = $roomNo1;
                            $modelHotelRate->int_personRoom = $personNo1;
                            /*$modelHotelRate->float_rackRatePackage = $rakRatePkg1;*/
                            $modelHotelRate->float_specialRatePackage = $spRatePkg1;
                            $modelHotelRate->float_rackRateHotel = $rkRateHtl1;
                            $modelHotelRate->float_specialRateHotel = $spcRatehtl1;
                            $modelHotelRate->save(false);
                            }

                        }
                    }

                }


            }

        }
  

“Undefined index:int_no_of_room20”作为错误....我得到了帖子值   正确....

1 个答案:

答案 0 :(得分:0)

使用此

if(isset($_POST['int_no_of_room'.$i.$j]))
     $roomType1      = $_POST['int_no_of_room'.$i.$j];
 else
     $roomType1 = "Not set !"