EllisLab text mark
Advanced Search
     
id with link
Posted: 04 January 2012 06:15 AM   [ Ignore ]
Joined: 2012-01-04
3 posts

i am a codeigniter biginner,  i have two files in my view folder. home.php and pages1.php.  design is same for both files. there are six links in both files. when i click on 6 links in home.php, i have to load pages1.php and data from databse related to this page. for this, we use id with Questian mark in normal php. how it done using codeigniter, i tried a lot. but not worked. please help me… all file attched with this post…....

 

 
Posted: 04 January 2012 06:32 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2011-12-28
164 posts

1) Don’t attach files.. just used BB [ code ] tags to wrap any code you want to write?

2) Are you super new to php. Your naming of functions and classes is shocking. I should be able to understand vaguely what a controller / model should do.

What is the Controller Contr/abc for?

What is newmodel/info1 supposed to get?

You need to work on your naming conventions.

3) The answer.. well you pass the id to the model..

function abc()
{
  $this
->load->model('newmodel');
  
$data['qry']=$this->newmodel->info1($id);
  
$this->load->view('home',$data);

You can also pass the id to the controller

function abc($id

This would accessed via the url contr/abc/1

Then in your model..

function info1($id)
{
  $this
->load->database();
  
$qry=$this->db->get_where('info',array('id'=>$id));
  return 
$qry->row_array();

Simples

 
Posted: 04 January 2012 07:27 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-01-04
3 posts

thankyou for you reply, i respects all your advises…... i am updating my codes, wll back again