CodeIgniter Forums
Tryng to view the details of a Table with the ID from a list, Help. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Tryng to view the details of a Table with the ID from a list, Help. (/thread-46111.html)



Tryng to view the details of a Table with the ID from a list, Help. - El Forum - 10-18-2011

[eluser]snoopy[/eluser]
Hello im new to codeigniter i have made some code for a site im creating and have been strugling with a problem, im not being able to create a function that gives me the data to display the details of a list item ( a table ) Thanks in advance, here is my code:

Controller:

Code:
function view_torrent_details()
        {
           $id = $this->input->post('id');
          
           $this->Main_model->get_id($id);
    
           $data ['query'] = $this->Main_model->get_id()->result();
          
           $this->load->view('view_torrent_details', $data);
            
        }

Model:
Code:
function get_id($id)
            {
                $query_str = "SELECT id FROM torrents WHERE id = ?";
                
                $result = $this->db->query( $query_str, $id );
                
                if ($result->num_rows() > 0)
                {
                    return true;
                } else { return false; }
            }

View:

Code:
foreach($query as $row)
  {
         echo form_open('main/view_torrent_details');
                $id = $row->id;
                form_input($id);
                echo form_submit(array('name' => 'detalhes'), 'Detalhes');
                echo form_close();
                echo '<tr><td width="350">' . anchor('main/view_torrent_details', $row->nome) . '</td>';
  echo '<td width="50" align="center">' . $row->tipo . '</td>';
  echo '<td width="50" align="center">' . $row->categoria . '</td>';
  echo '<td width="90" align="center">' . $row->formato . '</td></tr>';
  echo '<br />';  
                
  }