显示未定义的索引..编辑值未插入数据库
shows undefined index..edit values not inserting into database
i am using yii2, i need to insert edit values into database and edit
column is created by ajax. values in php column inserting
properly..thanks in advance
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" as the error....i got post values
properly....
使用这个
if(isset($_POST['int_no_of_room'.$i.$j]))
$roomType1 = $_POST['int_no_of_room'.$i.$j];
else
$roomType1 = "Not set !"
i am using yii2, i need to insert edit values into database and edit column is created by ajax. values in php column inserting properly..thanks in advance
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" as the error....i got post values properly....
使用这个
if(isset($_POST['int_no_of_room'.$i.$j]))
$roomType1 = $_POST['int_no_of_room'.$i.$j];
else
$roomType1 = "Not set !"