PHP does not run |
[eluser]hangbill[/eluser]
Hi Need some help please. Running on xampp, localhost. DB name = manual table = tbltopic field = Topic autoload-> $autoload['libraries'] = array('database'); have set db-> $db['default']['database'] = "manual"; So, seems the db should be available to this project controller <?php class Topic extends Controller { function Topic() { parent::Controller(); } function index() { $query = $this->db->get('tbltopic'); $this->load->view('topic_view', $data); } } ?> view <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html > <head> <title>Topics</title> </head> <body> <?php foreach ($query->result() as $row) { echo $row->Topic; } ?> </body> </html> Problem is page is blank on url http://localhost/CodeIgniter1.7.2/manual...c_view.php If I do a straight php echo, eg <?php echo "xxxxxx" ?> it works, but the code above does not return any results. Can anyone see what I am doing wrong. Thanks
[eluser]imn.codeartist[/eluser]
your problem is at your controller change your index function to the following and check where you have done wrong. Code: function index()
[eluser]hangbill[/eluser]
Thanks for trying to help; it still returns an empty page. There is a single value in the field 'Topic', which I can see in phpmyadmin, so am expecting the code to send it to the browser. Have checked that there is no whitespace before and after the php tags. Really cant figure this out.
[eluser]Phil Sturgeon[/eluser]
The problem is your URL. Quote:http://localhost/CodeIgniter1.7.2/manual...c_view.php You should not access your application like this, it will not work. Quote:http://localhost/CodeIgniter1.7.2/index.php/topic Remember that the first segment is the class, the second segment is the method then anything after that is parameters. Your URL has nothing to do with the views at all, they are handled by the controller. Also, please remember to use the [\code\] tags in your posts.
[eluser]hangbill[/eluser]
I've got it; appreciate your help, thanks very much. |
Welcome Guest, Not a member yet? Register Sign In |