![]() |
Data from database not showing up - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Data from database not showing up (/showthread.php?tid=23865) |
Data from database not showing up - El Forum - 10-23-2009 [eluser]GamingFusion[/eluser] I am trying to get data to display from a database onto an page for my removeShow page but it wont. After digging a bit i found that what ever code is below my getShows()function does not want to display. Whats wrong with it. Heres the model function getShows() Code: //getShows Function and heres my view page Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> and heres my controller Code: //removeShow Function Data from database not showing up - El Forum - 10-23-2009 [eluser]stratton[/eluser] GamingFusion, Try the modification below to your Model's method: Code: //getShows Function You also didn't post your entire controller so I'm going to assume that your Controller loads the model 'database' in the constructor? If not, make sure you include the following in your constructor; with the correct name of your model of course. Code: $this->load->model('Model_name'); Hope this helps! Data from database not showing up - El Forum - 10-23-2009 [eluser]khagendra[/eluser] Here is your model code Code: //getShows Function Your function getShows just retrieving the data from database but returning no result. So you have to add one more line like this Code: //getShows Function -- You also have to load the model in ur controller. if the class name of model is Model_name then u can load like this Code: class ControllerName extends Controller to fetch the data, within any function of that controller u can write like this Code: $this->Model_name->getShows(); The data will be return as array of objects. so u can write like this Code: $data['show_info'] = $this->Model_name->getShows(); Finally, the fields name can be fetched as in ur view like this Code: $show_info->field_name; Note: use the same name of loaded model while fetching the model function. Here is example Code: $this->load->model('Model_name'); Data from database not showing up - El Forum - 10-24-2009 [eluser]GamingFusion[/eluser] worked thanks man. |