cakephp - How to save multiple individual records for a single model -


i have model(friends), user can export friend's info facebook. want save friends info(id , name) mysql database.

i having trouble creating form same using form helper don't know exact number of friends each user.

is there easier way save user's friends database? (save multiple records same model)

basically should know how number of friends current user, right?

if so, loop following in view:

echo $this->form->create('user'); for($i=0;$i<$number_of_current_user_friends;$i++){   echo $this->form->input('friend.'.$i.'user_id', array('value'=>$current_user_id));   echo $this->form->input('friend.'.$i.'friend_name', array('value'=>$friends[$i]['name']));   echo $this->form->input('friend.'.$i.'fb_id', array('value'=>$friends[$i]['fb_id'])); } echo $this->form->end('submit'); 

then in controller save with:

$this->friend->saveall($this->data); 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -