2011-04-24 60 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

固定的,我是裝的觀點之前的數據