CodeIgniter Forums

Full Version: Form and user data advice needed!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]ede196620[/eluser]
Hello everyone I know this is long but pleas read everything i wanted to explain everything clearly.

I Am still new to codeigniter and the wonderful world of coding Smile. I am seeking advice i have a small project that i am working on for myself. I have a simple form that a user enters his details on one page and then is redirected to another page where he writes up a suggestions in a text box it also has some check boxes for suggestions, all this is split in to two tables in the database credentials table and suggestions table.

Also in the administrator dashboard i have a page where all these results are displayed that the user inputs with its credentials. I have everything echo out on the web page the data itself is displayed but not as it suppose to, the credentials data is not displaying with the correct user suggestions data. Is this because of something i am missing in my code or is ti something i have to do with the database ? I do have the foreign key set on the two tables linked by id. I am still new and dount know what is the next step to take to correct this.

If u have any advice plz post it it will be greatly appreciated tnx in advance.

El Forum

[eluser]TheFuzzy0ne[/eluser]
Please post your controller code.

El Forum

[eluser]ede196620[/eluser]
sorry it took so long to replay but here it is

Code:
function __construct()
{
  parent::__construct();
  $this->load->model('info_model','',TRUE);
}

    function getall($page_num=1){


        $results_per_page = 5;
        $this->load->model('info_model');
        $this->load->library('pagination');





        $config['base_url'] = 'http://localhost/Surva/index.php/info_controller/getall';
        $config['total_rows'] = $this->info_model->count_all();
         $config['per_page'] = $results_per_page;
         $config['use_page_numbers'] = TRUE;
        $config['num_links'] = 10;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);

        $data['query'] = $this->info_model->get_page($page_num, $results_per_page);
        $data['pagination'] = $this->pagination->create_links();
        $this->load->view('info_view', $data);




        }

El Forum

[eluser]TheFuzzy0ne[/eluser]
Sorry, I think we'll need the view as well. I'm not entirely sure what the problem is from your explanation, so I'm hoping that seeing the view might make it clearer.

Also, in your controller, you are loading info_model twice. Once in the constructor, and once in the getall() method.

El Forum

[eluser]ede196620[/eluser]
i know after posting i fixed the problem but tnx for noticing Smile well the problem is that is i do not know how to make my user data to group together lets say a user posts something in the form and i want that information be displayed in admits panel clearly separated from other user information i am asking do i need to write up a function for that or is it something to do with my database and the tables in the database should i use something like session ? here is my view

Code:
<html>
    <head>
     <title>Results</title>
<link href="<?php echo base_url(); ?>style/style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        
        <center>
            <div class="content">    
         &lt;?php echo anchor('http://localhost/Foram/index.php/home', 'Back to Dashboard'); ?&gt;
     <div class="data">          
         <table>
          <tr>
             <th>Name</th>
             <th>Second Name</th>
             <th>Phone</th>
             <th>Email</th>
             <th>Answer</th>
             <th>Comment</th>
             <th></th>
         </tr>
          &lt;?php foreach ($query as $row): ?&gt;
         <tr>      
             <td>&lt;?php echo $row->name; ?&gt;</td>
             <td>&lt;?php echo $row->second_name; ?&gt;</td>
             <td>&lt;?php echo $row->phone; ?&gt;</td>
             <td>&lt;?php echo $row->email; ?&gt;</td>
              <td> &lt;?php echo $row->sA;?&gt;
            &lt;?php echo $row->sB;?&gt;
            &lt;?php echo $row->sC;?&gt;</td>
             <td>&lt;?php echo $row->comment;?&gt;<br></td>  
            
            

         </tr>
        
        &lt;?php endforeach; ?&gt;
        
         </table>  
         &lt;?php if (isset($pagination))
          {
           echo $pagination;
           echo "<pre>"; var_dump($query);
           }
          ?&gt;      
   </div>
            </div>
        </center>
  
    &lt;/body&gt;
    &lt;/html&gt;

El Forum

[eluser]TheFuzzy0ne[/eluser]
I'm sorry, I'm having difficulty understanding what you mean. Can you give me an example of the data you'd expect to see on the page and the order you'd like it to be in?

El Forum

[eluser]ede196620[/eluser]
basically all i want is to organize my user data that when the admin looks at the results of suggestions all the suggestions will be with an appropriate user displayed on the page and the user can have multiple suggestions.

El Forum

[eluser]TheFuzzy0ne[/eluser]
You could use GROUP_CONCAT() to concatenate the comments, so you only get one row per user, and each row will contain all of the users comments.

You may find this useful: http://www.w3resource.com/mysql/aggregat...concat.php

El Forum

[eluser]ede196620[/eluser]
tnx for the help but i solved my problem using session i still have one question about the session class how do u select session id ?

El Forum

[eluser]TheFuzzy0ne[/eluser]
I think you can get the session ID with $this->session->userdata('session_id').

I'm not sure why you'd need it though. CodeIgniter generates a new one periodically, and using the session methods such as set_userdata, userdata(), set_flashdata and flash_data() you can set/get any information within the current session. The session ID should not be required by your app, unless you're extending the session library.
Pages: 1 2