我刚开始学习CI,今天在做一个小的程序,程序的流程是 文本框输入学生姓名,按钮点击提交之后查询数据库中这个学生考了多少分数
现在的问题是我本地测试的时候是没有问题的,但是上传到服务器之后就提示错误是
404 Page Not Found
The page you requested was not found.
我觉得应该是action 提交的地址不对,求大家帮我解答一下谢谢
我的form表单是这样写的
<form action="<?php echo site_url().'/getresult'?>" method="post"> <input name="cname" placeholder="请输入考生姓名" class="form-control" type="text"><br> <input name="ccert" placeholder="请输入准考证号" class="form-control" type="text"><br> <input value="提交" class="btn btn-info col-xs-12" type="submit"> </form>
class Getdb_model extends CI_Model { public function getresult() { /* 这里组合sql语句*/ /*$cname = $this->input->post('cname'); $cert = $this->input->post('ccert'); print_r($cname); print_r($cert); */ $cname = $this->input->post('cname'); $cert = $this->input->post('ccert'); $cname_item = 'username'; $data = $this->db->where(array('username'=>$cname))->get('exam_resu')->result_array(); return $data; }}
<?phpdefined('BASEPATH') OR exit('No direct script access allowed');class Getresult extends CI_Controller{ public function index() { $this->load->model('getdb_model','get'); $data['cj']=$this->get->getresult(); /* 下面再调用一个视图*/ $this->load->view('result',$data); } }
<table width="760" border="1"> <tr> <td>学生姓名</td> <td>准考证号</td> <td>单选题</td> <td>多选题</td> <td>填空题</td> <td>作图题</td> <td>简答题</td> <td>计算题</td> <td>试验题目</td> <td>总分</td> </tr> <tr> <?php foreach($cj as $v): ?> <td><?php echo $v['username'] ?></td> <td><?php echo $v['examnum'] ?></td> <td><?php echo $v['item_1'] ?></td> <td><?php echo $v['item_2'] ?></td> <td><?php echo $v['item_3'] ?></td> <td><?php echo $v['item_4'] ?></td> <td><?php echo $v['item_5'] ?></td> <td><?php echo $v['item_6'] ?></td> <td><?php echo $v['item_7'] ?></td> <td><?php echo $v['total'] ?></td> <?php endforeach ?> </tr></table>