我正在开展一个项目并坚持到底。我已经设计了一个表格,可以在数据库中插入一个人的个人资料详细信息....现在我想要的是,当人们提交条目到数据库后,提交后的下一页应该是输入的个人资料的预览,如人的图像名称和其他细节
这是我的控制器代码
public function listbusiness()
{
$this->load->model('client/Client_model');
$this->Client_model->checksession();
if($this->input->post("continue",TRUE)){
$ptype = $this->input->post('ptype');
$ftype = $this->input->post('ftype');
$peckage=array();
if($this->input->post('pktype1'))
{
$pk1=$this->input->post('pktype1');
$price1=$this->input->post('price1');
$peckage[$pk1]=$price1;
}
if($this->input->post('pktype2'))
{
$pk2=$this->input->post('pktype2');
$price2=$this->input->post('price2');
$peckage[$pk2]=$price2;
}
if($this->input->post('pktype3'))
{
$pk3=$this->input->post('pktype3');
$price3=$this->input->post('price3');
$peckage[$pk3]=$price3;
}
if($this->input->post('pktype4'))
{
$pk4=$this->input->post('pktype4');
$price4=$this->input->post('price4');
$peckage[$pk4]=$price4;
}
$sessiondata=array('ptype'=>$ptype,'ftype'=>$ftype,'pkage'=>$peckage);
$this->session->set_userdata($sessiondata);
$city = $this->input->post('City');
$this->session->set_userdata('city',$city);
}
if($this->input->post("submit",TRUE)){
//print_r($_POST);die;
//print_r($this->session->all_userdata());
//die;
$title = $this->input->post('title');
$desc = $this->input->post('desc');
$term = $this->input->post('term');
//$file = $this->input->files('files');
$add = $this->input->post('add');
//$name = $this->input->post('stud_name');
$bid = $this->session->userdata('logged_in');
//$file=str_replace(" ","_",$_FILES['stud_img']['name']);
$pp=implode($this->session->userdata('ptype'));
$ff=implode($this->session->userdata('ftype'));
$newdata=array("name"=>$title,
"detail"=>$desc,
"type"=>$pp,
"address"=>$add,
//"price"=>$price,
"facility"=>$ff,
"city"=>$this->session->userdata('city'),
"bussid"=>$bid['userid']);
//print_r($newdata);die;
$retval=$this->Client_model->save("listing",$newdata);
if($retval>0)
{
//print_r($newdata);die;
$apack=$this->session->userdata('pkage');
foreach($apack as $key=>$value)
{
$price=array("packtype"=>$key,"price"=>$value,'lid'=>$retval);
if($value!='')
{
$this->Client_model->save("price",$price);
}
}
if(isset($_FILES['files']))
{
$photoname=$_FILES['files']['name'];
$photopath=$_FILES['files']['tmp_name'];
$name=implode(",",$photoname);
$uploaddata=array("name"=>str_replace(" ","_",$name),"lid"=>$retval);
$retval1=$this->Client_model->saveupload("photo",$uploaddata);
if($retval1>0)
{
$size=count($photoname);
for($i=0;$i<$size;$i++)
{
$filename=str_replace(" ","_",$photoname[$i]);
move_uploaded_file($photopath[$i],$_SERVER['DOCUMENT_ROOT']."/clubhouz/upload/photo/".$filename);
}
}
}
//redirect("business/businessdetail");
//$insertid=base64_encode($value['id']);
// $insertid = $this->db->insert_id();
$insertid=base64_encode($value['id']);
redirect('viewlistdetail?id=$newid');
}
}
这是在模型中:
function viewlistdetail($st)
{
//echo $st;die;
$data['page_title'] = 'List View';
$data['detail']=$this->getlistdetail($st);
$this->load->view('client/general/head',$data);
$this->load->view('client/general/header');
$this->load->view('client/listview',$data);
$this->load->view('client/general/footer');
}
并且listview显示最后插入的记录, 但是在我提交表单后会出现页面未找到的错误。
答案 0 :(得分:-1)
请检查以下程序并将其应用于您的项目中。
你的controller
文件,我认为,它的文件名是persons.php
class Persons extends CI_Controller {
function view($id)
{
$this->load->model(array('Persons_model'));
$person = $this->Person_model->get_person($id);
$data['first_name'] = $person->first_name;
$data['last_name'] = $person->last_name;
$this->load->view('person_view', $data);
}
}
你的model
文件,我认为,它的文件名是persons_model.php
Class Persons_model extends CI_Model
{
function get_person($id)
{
$result = $this->db->get_where('persons', array('id'=>$id));
return $result->row();
}
{
您的view
文件,我认为,其文件名是person_view.php
<div>First Name: <?php echo $first_name ?></div>
<div>Last Name: <?php echo $last_name ?></div>