![]() |
Message: Undefined variable: rows ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Message: Undefined variable: rows ? (/showthread.php?tid=48690) Pages:
1
2
|
Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]solid9[/eluser] Hello anyone can help me with this. Error message: Code: A PHP Error was encountered Controller: Code: class Main extends CI_Controller { Model: Code: class Data_model extends CI_Model { View: Code: <div class='midnav'> Thanks in advanced. Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]John_Betong_002[/eluser] This post deleted so as not to confuse the issue. Please see following post. My apologies for being hasty and not checking the problem Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]Aken[/eluser] John, it has nothing to do with his query. You forgot to pass the data to your midnav view when you loaded and returned it. Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]solid9[/eluser] @aken thanks for the hint, But I already passed the data in the controller; Code: function show_user() { Sorry I'm noob, So what is missing in this codes? tnx n advanced. Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]John_Betong_002[/eluser] Try this: Code: function show_user() { edit: removed $this-> Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]LuckyFella73[/eluser] Just a hint: If your model method expects only one row as result it's easier to just return like this: Code: if ($query->num_rows() > 0) http://ellislab.com/codeigniter/user-guide/database/results.html And: if you pass data to your view you better do this: Code: $data['rows'] = $this->data_model->getAll(); instead of: Code: $this->data['rows'] = $this->data_model->getAll(); If you assign data to $this->whatever the values are available in your views anyway (without the need to pass them). Would be easier to find your error if you post both views and the actual controller code. But I guess its like Aken allready said: you have to pass the values to you midnav: Code: function show_user() Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]solid9[/eluser] @John_Betong sorry man your suggestion is not right... but thanks anyway. Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]solid9[/eluser] @luckyfella73 Thanks. I'll try that. Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]Jason Stanley[/eluser] Change this line. Code: $this->data['midnav'] = $this->load->view('data_model_test', null, TRUE); To Code: $this->data['midnav'] = $this->load->view('data_model_test', $this->data, TRUE); Have a look at how the views are made. Then it will make more sense to you. Quote:The third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser. The view is already processed and saved to a string. Passing data to your template file after this has happened won't do anything. Out of interest did you even try what Aken wrote? If you did this problem should have been solved 3 hours ago :roll: Message: Undefined variable: rows ? - El Forum - 01-25-2012 [eluser]solid9[/eluser] @jasonstanley LuckyFella is right, I only tweaked a little his work. Below is the right codes, Code: function show_user() { Problem Solved. Thanks again guys...!!! |