[eluser]xjermx[/eluser]
Thanks very much!
I'm reverse engineering my way through some code as I teach myself PHP and codeigniter.
I've got a followup question. I've spent a few days banging head against the wall trying to do something that I think is relatively simple.
I have an array which I'll pulled via a function in my model from a mysql database.
Code:
$data = $this->smoke_model1->list_users();
print_r($data);
gives me:
Quote:Array ( [multi] => Array ( [0] => stdClass Object ( [id] => 1 [name] => jerm1 [ip] => ) [1] => stdClass Object ( [id] => 2 [name] => name [ip] => ) [2] => stdClass Object ( [id] => 3 [name] => 0 [ip] => ) [3] => stdClass Object ( [id] => 4 [name] => 0 [ip] => ) [4] => stdClass Object ( [id] => 5 [name] => asdf56 [ip] => ) [5] => stdClass Object ( [id] => 6 [name] => asdf57 [ip] => ) [6] => stdClass Object ( [id] => 7 [name] => asdf58 [ip] => ) [7] => stdClass Object ( [id] => 8 [name] => asdf59 [ip] => ) [8] => stdClass Object ( [id] => 9 [name] => 0 [ip] => ) [9] => stdClass Object ( [id] => 10 [name] => bsdf2 [ip] => ) [10] => stdClass Object ( [id] => 11 [name] => laksdjie11 [ip] => ) [11] => stdClass Object ( [id] => 12 [name] => bargle2 [ip] => 75.66.223.193 ) [12] => stdClass Object ( [id] => 13 [name] => Booblesnort [ip] => 75.66.223.193 ) ) )
I am trying to fiddle with how that array is setup. Ultimately I'm trying to pass the data to a view, display the data with checkboxes and a submit button, and then based on which are checked, pass them back to the model to be deleted from the mysql table.
I've successfully passed the data to the view, and gotten it to display, but I think that I need to tweak the array - the lack of key names is throwing me off. I've managed to make the following code work for testing:
Code:
$data['multi'] = array(
array('name'=> 'xid[]','id'=>'78','name2'=>'Bob Barker','ip'=>'5465465465','value'=>'hi my name is Bob'),
array('name'=> 'xid[]','id' => '17','name2'=>'Joe Smith','ip'=>'255.255.255.0','value' => 'Hi my name is Joe'),
array('name'=> 'xid[]','id' => '14', 'name2' => 'Sam Turner','ip' =>'127.0.0.1','value'=> "Hi my name is Sam"),
);
because I can use foreach ($multi as $var) and make calls to $var and $var['name'] etc. Hence, my assumption is that if I can plug the values from my sql table into an array that has proper key names, then I can use them in the view.
Is there a simpler way to do this?