Passing query result back to controller / view... |
Helloooo,
So I have been following the tutorial in the user guide and am experimenting with them. In my News controller I have.. PHP Code: public function delete($id = NULL) And my Model.. PHP Code: public function delete_news($id) So by visiting news/delete/[post id] I delete the post in question. How to feed this back to my controller though? I'd like to load a view if successfully and a different view if not. I understand I can achieve this via an if statement in my controller, however how do I tell my controller the query was true/false? Sorry for the (I'm sure painfully simple) question ![]()
OK, so I have a result - however I'd love someone to tell me if I'm doing it the 'correct' CI way.
I'm keen to be as strict as possible with my syntax... Controller PHP Code: public function delete($id = NULL) Model PHP Code: public function delete_news($id) View PHP Code: <?php echo $result > 0 ? 'Post Deleted' : 'Nothing Happened....'; ?>
You have to load the view like this:
$this->load->view('view_name'); after the if and else condition. Remember to load the view always once in the function. ![]() |
Welcome Guest, Not a member yet? Register Sign In |