foreach in models and controller |
Helper
PHP Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); Model PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); MY_Controller PHP Code: class MY_Controller extends CI_Controller { When I use infoServer('with the name of value') The result is printed on the top page. But not where I would actually. Dentrol and variables or functions inside. Only at the top. While if I use it in a template it works perfectly. Any solution? I want to use the function so that when you call me the exact result, which it does, but it should work this way: This $variable = 'hello'; and this $variable = infoServer('with the name of value'); They should be the same. While at the time if I use the function produces the result I described before. Thanks for the support.
Don't use `echo` in model.
I removed the echo. But it does not work anyway. Now I do not print the result, but at the same time is not read even the variable.
EDIT:This problem occurs in both models * have a MY_Models* that controllers while in templates, with echo. It worked perfectly.
I can try to edit the model in this way:
PHP Code: public function info_server($name) { I also tried to remove the echo.But it does not solve the problem. The tag is not read dovre but should be printed first.
This is an example:
Obviously the error sql wanted. But as you can see the values that should be included in the query are written on top of everything. And this happens both in model * in this case * that in the controller. I think that is an error in Model, but I can not figure out how to solve. P.S. I can try to remove echo in the model but It does not solve the problem
(07-08-2015, 04:48 AM)kenjis Wrote:(07-08-2015, 02:47 AM)StratoKyke Wrote:(07-08-2015, 01:41 AM)kenjis Wrote: Don't use `echo` in model. I can try edit in this way: PHP Code: public function info_server($name) { But in this way It does not work anyway. I do not print variables above code, but it makes me even use.
It seems you don't know what `return` is.
`return` returns only one variable or value, and go back to where you called it.
|
Welcome Guest, Not a member yet? Register Sign In |