![]() |
How to pass multiple values from view->controller->model - 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: How to pass multiple values from view->controller->model (/showthread.php?tid=10587) |
How to pass multiple values from view->controller->model - El Forum - 08-05-2008 [eluser]johnmiller[/eluser] hi... I have a search page... The search fields are first_name, last_name, email, city, state etc... When i click the search button, i need to pass all these values to the controller and from there to model. how to pass all these values??? How to pass multiple values from view->controller->model - El Forum - 08-05-2008 [eluser]Pascal Kriete[/eluser] When you submit a form the values are added to the post array (or get - don't use that though). Then in your receiving controller you can access the fields like this: Code: $first_name = $this->input->post('first_name'); And to pass them to your model, you put them in an array, and pass it along as a parameter: Code: $data = array( How to pass multiple values from view->controller->model - El Forum - 08-05-2008 [eluser]Colin Williams[/eluser] It's a good idea to wrap your head around request methods and HTTP in general. Take the evening off and read this: http://www.w3.org/Protocols/ How to pass multiple values from view->controller->model - El Forum - 08-05-2008 [eluser]Eric Cope[/eluser] You probably should not access directly the post variables. Instead, check out Code Igniter's validation library. I use it extensively. Also, always assume your incoming data is dirty. If you do not assume this, you will regret it some time in the future. Reference the user manual, it is excellent. How to pass multiple values from view->controller->model - El Forum - 08-06-2008 [eluser]johnmiller[/eluser] thanks a lot... :-) How to pass multiple values from view->controller->model - El Forum - 08-07-2008 [eluser]johnmiller[/eluser] i tried passing one value... but didn't work.. this is my textbox Code: <input type="text" id="txt_fname" name="txt_fname" /> this is my button Code: <?php in the controller, i wrote Code: function do_search() but i am not getting $first_name value in the model. where i am making mistakes??? can you please help me? How to pass multiple values from view->controller->model - El Forum - 08-07-2008 [eluser]Eric Cope[/eluser] In your view, I would do this... Code: <?php echo $this->validation->error_string; // this echos the error string from validation?> in your controller... Code: <?php Remember, you can always look at the CI code too. Its not the Windows API! How to pass multiple values from view->controller->model - El Forum - 08-07-2008 [eluser]johnmiller[/eluser] my view Code: <?php echo $this->validation->error_string;?> my controller Code: function do_search() my model Code: function search_students($fname) but when i load search page, i get an error like Quote:Undefined property: CI_Loader::$validation where i have made mistake??? any idea??? How to pass multiple values from view->controller->model - El Forum - 08-07-2008 [eluser]Eric Cope[/eluser] you must load the validation library. In your model, you pass in $fname, but you use $first_name in the sql statement. How to pass multiple values from view->controller->model - El Forum - 08-07-2008 [eluser]johnmiller[/eluser] i have changed my model like this Code: function search_students($fname) i still get the error.. how to load the validation library??? the error i get is Quote:Severity: Notice The error is in the view Line number 272 is Code: <?php echo $this->validation->error_string;?> How to add the validation library? |