CI按钮提交表达查询数据库表达的action连接路径的问题
<br /> <form action="<?php echo site_url().'/getresult'?>" method="post"><br /> <br /> <input name="cname" placeholder="请输入考生姓名" class="form-control" type="text"><br><br /> <input name="ccert" placeholder="请输入准考证号" class="form-control" type="text"><br><br /> <input value="提交" class="btn btn-info col-xs-12" type="submit"><br /> </form>
class Getdb_model extends CI_Model {<br /> <br /> public function getresult()<br /> { <br /> /* 这里组合sql语句*/<br /> /*$cname = $this->input->post('cname');<br /> $cert = $this->input->post('ccert'); <br /> print_r($cname);<br /> print_r($cert);<br /> */<br /> $cname = $this->input->post('cname');<br /> $cert = $this->input->post('ccert'); <br /> $cname_item = 'username';<br /> $data = $this->db->where(array('username'=>$cname))->get('exam_resu')->result_array(); <br /> return $data;<br /> }<br />}
<?php<br />defined('BASEPATH') OR exit('No direct script access allowed');<br /><br />class Getresult extends CI_Controller{<br /> <br /> <br /> public function index()<br /> {<br /> <br /> $this->load->model('getdb_model','get');<br /> $data['cj']=$this->get->getresult();<br /> /* 下面再调用一个视图*/<br /> <br /> $this->load->view('result',$data);<br /> <br /> }<br /><br /> <br />}<br />
<table width="760" border="1"><br /> <tr><br /> <td>学生姓名</td><br /> <td>准考证号</td><br /> <td>单选题</td><br /> <td>多选题</td><br /> <td>填空题</td><br /> <td>作图题</td><br /> <td>简答题</td><br /> <td>计算题</td><br /> <td>试验题目</td><br /> <td>总分</td><br /> </tr><br /> <tr><br /> <?php foreach($cj as $v): ?><br /> <td><?php echo $v['username'] ?></td><br /> <td><?php echo $v['examnum'] ?></td><br /> <td><?php echo $v['item_1'] ?></td><br /> <td><?php echo $v['item_2'] ?></td><br /> <td><?php echo $v['item_3'] ?></td><br /> <td><?php echo $v['item_4'] ?></td><br /> <td><?php echo $v['item_5'] ?></td><br /> <td><?php echo $v['item_6'] ?></td><br /> <td><?php echo $v['item_7'] ?></td><br /> <td><?php echo $v['total'] ?></td><br /> <?php endforeach ?><br /><br /> </tr><br /></table>