<?php
include 'include/db.php';
include 'include/connect.php';

$id = $_POST['id'];
$day = $_POST['allx'];
$idedit = $_POST['edits'];
    
    // if(!empty($idedit)){
    //   for ($i = 1; $i<= (int)$day; $i++){ 
    //   $idapppro = $_POST['idpro'.$i.''];
    //   $data2['pass_iv'] = $_POST['code'];
    //   // $data2['pass_pic'] = $_POST['image_field2'.$i.''];
    //   $data2['pass_pic'] = $_POST['image_field'.$i.''];
    //   $data2['pass_name'] = $_POST['name'.$i.''];

    //   $data2['pass_title_eg'] = $_POST['pass_title_eg'.$i.''];
    //   $data2['pass_name_eg'] = $_POST['pass_name_eg'.$i.''];
    //   $data2['pass_lastname_eg'] = $_POST['pass_lastname_eg'.$i.''];
    //   $data2['pass_title_th'] = $_POST['pass_title_th'.$i.''];
    //   $data2['pass_name_th'] = $_POST['pass_name_th'.$i.''];
    //   $data2['pass_lastname_th'] = $_POST['pass_lastname_th'.$i.''];

    //   $ro = $db->update('tbpass',$data2,'pass_id',$idapppro);   
    //   }
            
    //   if($ro){
    //             echo '0';
    //             } else{
    //             echo '00';
    //             }          

    // } else {    
    //    if($_POST['code'] != ""){
    //     for ($i = 1; $i<= (int)$day; $i++){
    //     $rs = $db->insert('tb_programe',array(
    //    'programe_code' => $_POST['programe_code'.$i.''],
    //    'programe_name' => $_POST['programe_name'.$i.''],
    //    'programe_price' => $_POST['programe_price'.$i.''],
    //    'programe_airline' => $_POST['programe_airline'.$i.''],
    //    'tag_lastname_th' => $_POST['tag_lastname_th'.$i.''],
    //    'programe_route' => $_POST['programe_route'.$i.''],
    //    'programe_time' => $_POST['programe_time'.$i.''],
    //    'programe_datego' => $_POST['programe_datego'.$i.''],
    //    'programe_dateback' => $_POST['programe_dateback'.$i.''],
    //    'programe_country' => $_POST['programe_country'.$i.''],
    //    'programe_img' => $_POST['programe_img'.$i.''],
    //    'programe_file' => $_POST['programe_file'.$i.''],
    //         )); 
    //    }

    //       if($rs){
            
    //         echo '2';
           
    //         }else {
                
    //         echo '00';
    //         }           
        
    //   } else {
    //     echo "3";
    // }         
        
    //   }

        for ($i = 1; $i<= (int)$day; $i++){
        $rs = $db->insert('tb_programe',array(
       'programe_code' => $_POST['programe_code'.$i.''],
       'programe_wholesale' => "5",
       'programe_name' => $_POST['programe_name'.$i.''],
       'programe_price' => $_POST['programe_price'.$i.''],
       'programe_airline' => $_POST['programe_airline'.$i.''],
       // 'tag_lastname_th' => $_POST['tag_lastname_th'.$i.''],
       'programe_hilight' => $_POST['programe_hilight'.$i.''],
       'programe_time' => $_POST['programe_time'.$i.''],
       'programe_datego' =>"-",
       'programe_dateback' => "-",
       'programe_country' => $_POST['programe_country'.$i.''],
       'programe_img' => $_POST['programe_img'.$i.''],
       'programe_file' => $_POST['programe_file'.$i.''],
            )); 
       }

          if($rs){
            
            echo '2';
           
            }else {
                
            echo '00';
            }   

?>





