如何在使用多个表单的codeigniter中加载视图

时间:2015-04-19 14:59:21

标签: php codeigniter

这是我的观点:

<form action="HomeController.php" method="post">
    Available Batches:<select name="batch">
    <?php  mysql_connect('localhost','root','');
    mysql_select_db('login');
    $sql = "SELECT b_id FROM batch where type='C#'and seats_left!=0";
    $result=  mysql_query($sql);
    while ($row = mysql_fetch_array($result)){
    ?>
    <option value="" ><?php echo $row["b_id"];?></option>
    <?php
    }
    ?>
    </select><br>
    <input type="submit" name="new" value="new"><br>
</form>

<?php echo form_open('HomeController/Enteringdata') ?>
Enter batch id:<input type="text" name="b"><br>
<input type="submit" name="enter" value="enter"><br>

这是我的控制者:

public function Enteringdata() {
    if($this->input->post('enter')=="enter"){
        $b= $this->input->post('b');
        $this->load->Model('LoginModel');
        $seats=$this->LoginModel->batch($b);
        $seats--;
        $this->LoginModel->ins($seats,$b);
    }
    elseif($this->input->post('new')=="new")
    {
        $this->load->view('batchc'); 
    }
}

0 个答案:

没有答案