How to use variable in flash message |
[eluser]debow[/eluser]
Can someone help with the below issue. All I'm wanting to do is use the users first name that gets deleted in the message after they are deleted. Code: function pdelete($options = array()) { The $name is not showing up at all. I know I doing something wrong but not sure what. I've tried it many different ways.
[eluser]cideveloper[/eluser]
So I assume when you run this Code: echo $this->session->flashdata('message'); you get a response like this "User has been deleted" have you tried just showing the passed in options array to make sure the values are being passed into function pdelete properly. Code: function pdelete($options = array()) { Also could you show the result of the above.
[eluser]debow[/eluser]
The response I get is "User has been deleted" The result from the code you gave is just 1. I assume that's because there is only 1 record being deleted but I could be wrong. I don't have to have my message display this way but I like the ideal of it giving me more info on what was deleted.
[eluser]cideveloper[/eluser]
if you are getting "1" as a response to the print_r($options), you are not passing an array to your pdelete function. Can you show what is calling that function. Is "1" the id of the user you want to delete?
[eluser]debow[/eluser]
Ok, so I've had this setup many diff ways. Here's the full flow now. In my view I have a table showing all the athletes. I have actions such as view/update/del. In the controller that loads that view I have the actions items anchored with this. Code: anchor('athletes/delete/' . $athlete->athId, 'del', array('class' => 'delete', 'onclick' => "return confirm('Are you sure want to delete this user?')")) If I click on del it then calls the below function. This is how it looks now a little diff then the options array I was passing. Both worked by deleting the user. Its just a matter of getting my message the way I'd like. Code: function delete($athId) {
[eluser]cideveloper[/eluser]
Is $this->athletes_model->GetAthlete(array('athId' => $athId)); returning an array with athfirst, athId, etc.? than you would access $name like this $data['athlete']['athfirst']
[eluser]debow[/eluser]
Yes, I tried using this Code: $name = $data['athlete']['athfirst']; But got the following error. Fatal error: Cannot use object of type stdClass as array in othd\controllers\athletes.php on line 161
[eluser]cideveloper[/eluser]
so you are not returning an array. try this. Code: $name = $data['athlete']->athfirst I am only guessing here and can help more if I can see GetAthlete function in athletes_model Model.
[eluser]debow[/eluser]
Thank you very much that worked. I'll look at my query and try to better understand why I wasn't returning an array but thought I was. Thanks.
[eluser]cideveloper[/eluser]
[quote author="debow" date="1305080448"]Thank you very much that worked. I'll look at my query and try to better understand why I wasn't returning an array but thought I was. Thanks.[/quote] NP. You dont have to return a result array. I never do. I like returning object like you did. check out this but then I would change Code: $data['athlete'] = $this->athletes_model->GetAthlete(array('athId' => $athId)); to the simplified version Code: $ath_data = $this->athletes_model->GetAthlete(array('athId' => $athId)); |
Welcome Guest, Not a member yet? Register Sign In |