2014-10-20 58 views
0

我已閱讀用戶指南和教程的這個顯示單選按鈕,我還是新國際展覽局在這個時候代碼點火器這麼難了解它, 我怎樣才能在單選按鈕檢查?如何從數據庫中使用笨

非常感謝

這裏是我的控制器

public function updateProduct($id) 
 
\t { 
 
\t $data['product'] = $this->products_model->getProduct($id); 
 
    $this->load->view('update_product_view', $data); 
 
\t } 
 
\t 
 
\t public function updateProductDb() 
 
\t { 
 
\t $data=array(
 
\t \t \t \t \t 'nama'=>$this->input->post('nama'), 
 
\t \t \t \t \t 'umur'=>$this->input->post('umur'), 
 
\t \t \t \t \t 'hoby'=>$this->input->post('hoby'), 
 
\t \t \t \t \t 'jk'=>$this->input->post('jk'), 
 
\t \t \t \t \t 'alamat'=>$this->input->post('alamat')); 
 
\t \t $condition['id'] = $this->input->post('id'); 
 
\t \t $this->products_model->updateProduct($data, $condition); 
 
\t \t redirect('products'); 
 
\t \t }

here is my model 
 

 
<?php 
 
//File products_model.php 
 
\t class Products_model extends CI_Model { 
 
\t \t function __construct() { parent::__construct(); } function getAllProducts() { 
 
\t \t //select semua data yang ada pada table msProduct $this--->db->select("*"); 
 
\t \t $this->db->from("anggota"); 
 
\t \t return $this->db->get(); 
 
\t } 
 
\t 
 
\t //iNI BERFUNGSI UNTUK GET DATA YANG DI PILIH BERDASARKAN ID ATAU USER YANG KLIK */ 
 
\t function getProduct($id) 
 
\t { 
 
\t \t //select produk berdasarkan id yang dimiliki \t 
 
     $this->db->where('id', $id); //Akan melakukan select terhadap row yang memiliki productId sesuai dengan productId yang telah dipilih 
 
     $this->db->select("*"); // SELECT ALL 
 
     $this->db->from("anggota"); //TABEL 
 
     
 
     return $this->db->get(); 
 
\t } 
 
\t function addProduct($data) 
 
\t { 
 
\t //untuk insert ke database 
 
\t $this->db->insert('anggota',$data); 
 
\t } 
 
\t 
 
\t function updateProduct($data, $condition) 
 
\t { 
 
\t \t //update produk 
 
     $this->db->where($condition); //Hanya akan melakukan update sesuai dengan condition yang sudah ditentukan 
 
     $this->db->update('anggota', $data); //Melakukan update terhadap table msProduct sesuai dengan data yang telah diterima dari controller 
 
\t } 
 
\t function deleteProduct($id) 
 
\t { 
 
\t \t //delete produk berdasarkan id 
 
     $this->db->where('id', $id); 
 
     $this->db->delete('anggota'); 
 
\t } 
 
\t 
 
\t }

這種觀點

<input type="text" name="jk" value="<?php echo $detail->jk; ?>">

回答

0

試試這個,添加它的控制器,你打電話給你的觀點之前

$radio_data = array(
    'name'  => 'jk', 
    'id'   => 'jk', 
    'value'  => $detail->jk, 
    'checked'  => TRUE, 
    'style'  => 'margin:10px', 
    ); 

$data['jk']=form_radio($radio_data); 
+0

它通過使用這個父親 hoby ==「Lari」)'); ?> />拉里 \t \t \t \t \t \t \t HOBY ==」 Berenang「)'); ?> /> Berenang – 2014-10-20 10:26:44

+0

順便說一句,謝謝你的答覆:D – 2014-10-21 01:52:13