Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用codeigniter更新数据库,并在同一页面中显示更新_Php_Jquery_Ajax_Database_Codeigniter - Fatal编程技术网

Php 使用codeigniter更新数据库,并在同一页面中显示更新

Php 使用codeigniter更新数据库,并在同一页面中显示更新,php,jquery,ajax,database,codeigniter,Php,Jquery,Ajax,Database,Codeigniter,我试图通过php CodeIgniter将数据更新到数据库中,并在更新期间在同一页面中显示结果。下面是我的代码。问题是它没有显示任何错误消息,没有更新数据库中的值,更新后也没有在页面中显示任何值。请帮忙。 查看页面 <?php echo form_open('Welcome/service1'); ?> <input type="hidden" name="servicer_id" value="<?php echo $value['service_id']?

我试图通过php CodeIgniter将数据更新到数据库中,并在更新期间在同一页面中显示结果。下面是我的代码。问题是它没有显示任何错误消息,没有更新数据库中的值,更新后也没有在页面中显示任何值。请帮忙。 查看页面

<?php 
  echo form_open('Welcome/service1'); 
?> 

<input type="hidden" name="servicer_id" value="<?php echo $value['service_id']?>">
<input type="hidden" name="servicer_name" value="<?php echo $value['servicer_name']?>">
<input type="hidden" name="servicer_email" value="<?php echo $value['servicer_email']?>">
<input type="hidden" name="servicer_checkin" value="<?php echo $value['servicer_checkin']?>">
<input type="hidden" name="servicer_checkout" value="<?php echo $value['servicer_checkout']?>">
<input type="hidden" name="servicer_requestdate" value="<?php echo $value['servicer_requestdate']?>">
<input type="hidden" name="servicer_detail" value="<?php echo $value['servicer_detail']?>">
<input type="hidden" name="servicer_contact" value="<?php echo $value['servicer_contact']?>">
<input type="hidden" name="servicer_priority" value="<?php echo $value['servicer_priority']?>"> 
<label class="radio-inline">
    <input type="radio" <?php if($value['status']=="Complete") {?> checked="checked"<?php } ?> name="current_status" value="Complete">Complete
</label>
<label class="radio-inline">
    <input type="radio" <?php if($value['status']=="Ongoing") {?> checked="checked"<?php } ?> name="current_status" value="Ongoing">Ongoing
</label>
<label class="radio-inline">
    <input type="radio" <?php if($value['status']=="Rejected") {?> checked="checked"<?php } ?> name="current_status" value="Rejected">Rejected
</label>
<button type="submit" class="btn btn-default">
    <span>Status</span>
</button>   

<?php 
    echo form_close(); 
?>
Controller page
public function service1()
{                    
    $this->load->helper('url');
    $page_id =$this->uri->segment(3);
    $this->load->model('Login_set');  
    $this->Login_set->add_status();
    $data['s']=$this->Login_set->select2(); 
    $this->load->view('App_stay/pages/hotel1_service.php',$data);
}

Model page

public function add_status() 
{
    this->load->database();
    this->load->helper('url');
    hotel_id=1;
    servicer_name= $this->input->post('servicer_name');
    servicer_email= $this->input->post('servicer_email'); 
    servicer_checkin= $this->input->post('servicer_checkin');
    servicer_checkout= $this->input->post('servicer_checkout');
    servicer_requestdate= $this->input->post('servicer_requestdate');
    servicer_detail= $this->input->post('servicer_detail');
    servicer_contact= $this->input->post('servicer_contact');
    servicer_priority= $this->input->post('servicer_priority');
    status= $this->input->post('status');
    service_id= $this->input->post('servicer_id');
    data=array('hotel_id'=>$hotel_id,'servicer_name'=>$servicer_name,'servicer_email'=>$servicer_email,'servicer_checkin'=>$servicer_checkin,'servicer_checkout'=>$servicer_checkout,'servicer_requestdate'=>$servicer_requestdate,'servicer_detail'=>$servicer_detail,'servicer_contact'=>$servicer_contact,'servicer_priority'=>$servicer_priority,'status'=>$status);
    this->db->where('service_id',$service_id);
    this->db->update('service_hotel1',$data);            
}


您正在将输入传递给模型,但它们正在传递给控制器函数。。请更新

控制器:

public function service1()
{
    /** you are posting the form to this function and not to the model.
    *   which is why all input->post must be here
    */
    $servicer_name       = $this->input->post('servicer_name');
    $servicer_email      = $this->input->post('servicer_email');
    $servicer_checkin    = $this->input->post('servicer_checkin');
    $servicer_checkout   = $this->input->post('servicer_checkout');
    $servicer_requestdate= $this->input->post('servicer_requestdate');
    $servicer_detail     = $this->input->post('servicer_detail');
    $servicer_contact    = $this->input->post('servicer_contact');
    $servicer_priority   = $this->input->post('servicer_priority');
    $status              = $this->input->post('status');
    $service_id          = $this->input->post('servicer_id');


    $this->load->helper('url');
    $page_id = $this->uri->segment(3);
    $this->load->model('Login_set');
    $this->Login_set->add_status($servicer_name, $servicer_email, $servicer_checkin, $servicer_checkout, $servicer_requestdate, $servicer_detail, $servicer_contact, $servicer_priority, $status, $service_id);
    $data['s'] = $this->Login_set->select2();
    $this->load->view('App_stay/pages/hotel1_service',$data); //also view must be loaded without .php so $this->load->view('App_stay/pages/hotel1_service',$data);
}
型号:

public function add_status($servicer_name, $servicer_email, $servicer_checkin, $servicer_checkout, $servicer_requestdate, $servicer_detail, $servicer_contact, $servicer_priority, $status, $service_id)
{
    $this->load->database();
    $this->load->helper('url');
    $hotel_id =1 ;
    $data = array(
        'hotel_id'             => $hotel_id,
        'servicer_name'        => $servicer_name,
        'servicer_email'       => $servicer_email,
        'servicer_checkin'     => $servicer_checkin,
        'servicer_checkout'    => $servicer_checkout,
        'servicer_requestdate' => $servicer_requestdate,
        'servicer_detail'      => $servicer_detail,
        'servicer_contact'     => $servicer_contact,
        'servicer_priority'    => $servicer_priority,
        'status'               => $status
    );

    $this->db->where('service_id',$service_id);
    $this->db->update('service_hotel1',$data);
}

您正在将输入传递给模型,但它们正在传递给控制器函数。。请更新

控制器:

public function service1()
{
    /** you are posting the form to this function and not to the model.
    *   which is why all input->post must be here
    */
    $servicer_name       = $this->input->post('servicer_name');
    $servicer_email      = $this->input->post('servicer_email');
    $servicer_checkin    = $this->input->post('servicer_checkin');
    $servicer_checkout   = $this->input->post('servicer_checkout');
    $servicer_requestdate= $this->input->post('servicer_requestdate');
    $servicer_detail     = $this->input->post('servicer_detail');
    $servicer_contact    = $this->input->post('servicer_contact');
    $servicer_priority   = $this->input->post('servicer_priority');
    $status              = $this->input->post('status');
    $service_id          = $this->input->post('servicer_id');


    $this->load->helper('url');
    $page_id = $this->uri->segment(3);
    $this->load->model('Login_set');
    $this->Login_set->add_status($servicer_name, $servicer_email, $servicer_checkin, $servicer_checkout, $servicer_requestdate, $servicer_detail, $servicer_contact, $servicer_priority, $status, $service_id);
    $data['s'] = $this->Login_set->select2();
    $this->load->view('App_stay/pages/hotel1_service',$data); //also view must be loaded without .php so $this->load->view('App_stay/pages/hotel1_service',$data);
}
型号:

public function add_status($servicer_name, $servicer_email, $servicer_checkin, $servicer_checkout, $servicer_requestdate, $servicer_detail, $servicer_contact, $servicer_priority, $status, $service_id)
{
    $this->load->database();
    $this->load->helper('url');
    $hotel_id =1 ;
    $data = array(
        'hotel_id'             => $hotel_id,
        'servicer_name'        => $servicer_name,
        'servicer_email'       => $servicer_email,
        'servicer_checkin'     => $servicer_checkin,
        'servicer_checkout'    => $servicer_checkout,
        'servicer_requestdate' => $servicer_requestdate,
        'servicer_detail'      => $servicer_detail,
        'servicer_contact'     => $servicer_contact,
        'servicer_priority'    => $servicer_priority,
        'status'               => $status
    );

    $this->db->where('service_id',$service_id);
    $this->db->update('service_hotel1',$data);
}