0
我有這個註冊碼:打印CodeIgniter同一頁上的表格的結果
a。控制器
<?php
class Manual extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model("model_manual");
}
public function index(){
$this->insert();
}
public function insert()
{
$this->form_validation->set_rules('nama', 'Nama', 'required');
\t \t $this->form_validation->set_rules('npm', 'Npm', 'required');
$this->form_validation->set_rules('matkul','Matkul','required');
if ($this->form_validation->run())
{
$register=$this->model_manual->insertdata($_POST);
if($register){
echo "<script>alert('Input Sucessfully')</script>";
\t \t \t \t \t }
}
$data['title']="Input data";
\t \t $data=array('isi' \t =>'home/manual_view');
\t \t $this->load->view('layout/wrapper',$data);
}
}
?>
灣模型
<?php
class Model_manual extends CI_Model {
\t \t function insertdata($options = array()){
if(isset($options['nama']))
$this->db->set('nama',strip_tags($options['nama']));
if(isset($options['npm']))
$this->db->set('npm',strip_tags($options['npm'])); \t \t \t
if(isset($options['matkul']))
$this->db->set('matkul',($options['matkul']));
$this->db->insert("tabel_manual");
return $this->db->insert_id();
\t \t }
\t
\t \t function cek_user($data) {
\t \t \t $query = $this->db->get_where('tabel_manual', $data);
\t \t \t return $query;
\t \t }
\t \t
\t \t function getAllUser() {
\t \t $this->db->from('tabel_manual');
\t \t return $this->db->get();
\t \t }
\t \t
}
?>
℃。鑑於
<div class = "well" style = "background-color :lavender;">
<button class="btn btn-default" style= "padding-top : 9px; padding-bottom : 9px;"><a href = "<?php echo base_url(); ?>home" style = "text-decoration : none;"><span class="glyphicon glyphicon-home"></span></a></button>
<button class="btn btn-default"><a href = "<?php echo base_url(); ?>blanko" style = "text-decoration : none;"><span class="glyphicon glyphicon-list-alt"></span> Blanko</a></button>
<div class = "row">
<div class = "col-sm-offset-3 col-sm-6" style = "text-align : center">
<label style = "font-size: 20px;">INPUT DATA</label>
</div>
<div class = "row">
<div class = "col-sm-offset-4 col-sm-4">
<form class="form-horizontal" action="" method="post" style = "margin : 10px;">
\t \t
\t \t <div class="form-group">
\t \t <label style = "font-family : cambria;">Nomor Pokok Mahasiswa :</label>
\t \t <input style = "font-family : cambria;" type="text" class="form-control" placeholder = "Typehere"
\t \t name="npm" id="npm"/>
\t \t <font color="#FF0000"><?php echo form_error('npm');?></font>
\t \t </div>
\t \t
\t \t <div class="form-group">
\t \t <label style = "font-family : cambria;">Nama Lengkap :</label>
\t \t <input style = "font-family : cambria;" type="text" class="form-control" placeholder = "Typehere"
\t \t name="nama" id="nama"/>
\t \t <font color="#FF0000"><?php echo form_error('nama');?></font>
\t \t </div>
\t \t \t \t
\t \t <div class="form-group"> \t
\t \t <label style = "font-family : cambria;">Mata Ujian :</label>
\t \t <select class="form-control" name="matkul" id="matkul">
\t \t <option value="">Select</option>
\t \t <option value="pancasila">Pancasila</option>
\t \t <option value="matdas2">Matematika Dasar 2</option>
\t \t <option value="ap2">Algo.Pemograman 2</option>
\t \t <option value="ap3">Algo.Pemograman 3</option>
\t \t <option value="matif4">Matematika Informatika 4</option>
\t \t <option value="sisber">Sistem Berkas</option>
\t \t <option value="arkom">Arsitektur Komputer</option>
\t \t <option value="jarkom">Jaringan Komputer</option>
\t \t <option value="si">Sistem Informasi</option>
\t \t <option value="so">Sistem Operasi</option>
\t \t <option value="imk">IMK</option>
\t \t <option value="sbd2">SBD 2</option>
\t \t <option value="tbo">TBO</option>
\t \t <option value="rpl2">RPL 2</option>
\t \t </select>
\t \t <font color="#FF0000"><?php echo form_error('matkul');?></font>
\t \t </div>
\t \t
\t \t <br>
\t \t <div class="form-group"> \t
<button type="submit" class="btn btn-default" style = "font-family : cambria; ">Input</a></button>
\t \t <button type="reset" class="btn btn-default" style = "font-family : cambria;">Reset</button>
\t \t </div>
\t </div>
\t </div>
\t </form>
\t
</div>
</div>
的觀點,我使用的引導,使我的界面設計。 問題是...我怎樣才能打印表單的結果去我「點擊」提交按鈕在同一頁面?
我只是想讓表單,然後在那個表單下面,我可以顯示結果。
你能告訴我嗎?我不明白:( –
請給我一些時間,我會告訴你...... –
好的。謝謝 –