2011-04-24 62 views
-1

我有一个问题,当我点击一个链接来编辑销售http://domain/admin/editsale/index/21/sale-name我似乎得到一个空白页面加载,所以我有一种感觉,它没有得到$id,但我不能发现我的问题。编辑页面 - >加载空白页面

控制器:

if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class Editsale extends CI_Controller { 

    function __construct() { 
    parent::__construct(); 

    } 

    function index($id) { 
     if(!$this->session->userdata('logged_in'))redirect('admin/home'); 

     if($this->input->post('submit')) { 

      #Set The Validation Rules 
       $this->form_validation->set_rules('name', 'Name', 'trim|required'); 
       $this->form_validation->set_rules('location', 'Location', 'trim|required'); 
       $this->form_validation->set_rules('bedrooms', 'Bedrooms', 'trim|is_natural'); 
       $this->form_validation->set_rules('bathrooms', 'Bathrooms', 'trim'); 
       $this->form_validation->set_rules('condition', 'Condition', 'trim'); 
       $this->form_validation->set_rules('description', 'Description', 'trim'); 
       $this->form_validation->set_rules('price', 'Price', 'trim'); 

      if($this->form_validation->run() == FALSE) { 

       #Set the $data for the view if FALSE 
       $data['cms_pages'] = $this->navigation_model->getCMSPages($id); 
       $data['sales_pages'] = $this->sales_model->getSalesPages($id); 
       $data['sale'] = $this->sales_model->getSalesContent($id); 
       $data['content'] = $this->load->view('admin/editsale', $data, TRUE); #Loads the "content" 

       $this->load->view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it 
      } 

      #Form Validation Was Correct So Lets Continue 

      #Lets Set What We Are Sending To The DB 
        $content = array(
        'name' => $this->input->post('name', TRUE), 
        'location' => $this->input->post('location', TRUE), 
        'bedrooms' => $this->input->post('bedrooms', TRUE), 
        'bathrooms' => $this->input->post('bathrooms', TRUE), 
        'condition' => $this->input->post('condition', TRUE), 
        'description' => $this->input->post('description', TRUE), 
        'price' => $this->input->post('price', TRUE) 
        ); 

        if($this->sales_model->updateSale($id, $content)) { 
          $data['success'] = TRUE; #displays sale updated 
          $data['cms_pages'] = $this->navigation_model->getCMSPages($id); 
          $data['sales_pages'] = $this->sales_model->getSalesPages($id); 
          $data['sale'] = $this->sales_model->getSalesContent($id); 
          $data['content'] = $this->load->view('admin/editsale', $data, TRUE); #Loads the "content" 
       } // Sale Update End 
        }else{ 
       $data['cms_pages'] = $this->navigation_model->getCMSPages($id); 
       $data['sales_pages'] = $this->sales_model->getSalesPages($id); 
       $data['sale'] = $this->sales_model->getSalesContent($id); 
       $data['content'] = $this->load->view('admin/editsale', $data, TRUE); #Loads the "content" 
       }#Submit End  
     } #Index End 
} 

型号:

function getSalesPages($id = NULL) { 
    $query = $this->db->get('sales'); 
    if($query->num_rows() > 0) return $query->result(); 

} 

function getSalesContent($id = NULL) { 
    $this->db->where('id', $id); 
    $query = $this->db->get('sales', 1); 

    if($query->num_rows() > 0) { 
     $row = $query->result_array(); 
     return $row; 
    }else{ 
     return FALSE; 
    } 
} 

查看:

<?php 
//Setting form attributes 
$formEditSale = array('id' => 'editSale', 'name' => 'editSale'); 
$formName = array('id' => 'name', 'name' => 'name'); 
$formLocation = array('id' => 'location', 'name' => 'location'); 
$formBedrooms = array('id' => 'bedrooms','name' => 'bedrooms'); 
$formBathrooms = array('id' => 'bathrooms','name' => 'bathrooms'); 
$formCondition = array('id' => 'condition','name' => 'condition'); 
$formDescription = array('id' => 'description','name' => 'description'); 
$formPrice = array('id' => 'price','name' => 'price'); 

if($success == TRUE) { 
echo '<section id = "validation">Sale Updated</section>'; 
} 
?> 

?> 

<section id = "validation"><?php echo validation_errors();?></section> 

<?php 
echo form_open_multipart('admin/editsale/index/'.$sale[0]['id'].'/'.url_title($sale[0]['name'],'dash', TRUE),$formEditSale); 
echo form_fieldset(); 
echo form_label('Name:', 'name'); 
echo form_input($formName, $sale[0]['name']); 
echo form_label ('Location', 'location'); 
echo form_input($formLocation, $sale[0]['location']); 
echo form_label ('Bedrooms', 'bedrooms'); 
echo form_input($formBedrooms, $sale[0]['bedrooms']); 
echo form_label ('Bathrooms', 'bathrooms'); 
echo form_input($formBathrooms, $sale[0]['bathrooms']); 
echo form_label ('Condition', 'condition'); 
echo form_input($formCondition, $sale[0]['condition']); 
echo form_label ('Price', 'price'); 
echo form_input($formPrice, $sale[0]['sale']); 
echo form_label ('Description', 'description'); 
echo form_textarea($formDescription, $sale[0]['description']); 
echo form_submit('submit','Submit'); 
echo form_fieldset_close(); 
echo form_close(); 
+0

你的'display_errors'设置为关闭?使用PHP,如果在脚本启​​动过程中有任何致命错误,并且display_errors关闭,那么您只能看到白色屏幕。检查你的服务器的错误日志以获取更多细节。 – 2011-04-24 02:43:32

回答

0

固定的,我是装的观点之前的数据