dennismonsewicz Posted September 22, 2009 Share Posted September 22, 2009 Apparently I just need to give it up when it comes to loops lol... this is like the third time I have needed help on loops... Anyway, I have this code: while(list($key, $value) = each($_FILES['userfile']['name'])) { if(!empty($value)) { $this->multi_upload->go_upload(); $albumId = $this->input->post('album'); $songTitle = str_replace(" ", "_", $value); $audio->album_id = $albumId; $audio->title = $songTitle; $audio->file_path = '../primary_app/binary/' . $artistName . '/audio/'; $audio->active = 1; $audio->created_at = new Doctrine_Expression('NOW()'); $audio->updated_at = new Doctrine_Expression('NOW()'); $audio->save(); $counter++; } else { $counter = 0; } } The problem is that it is only adding the last submitted file into the DB (ex: if I upload 3 files, the last file in the list gets added to the DB instead of ALL of them). The $counter var is for an error checking if statement I have later in the script Link to comment https://forums.phpfreaks.com/topic/175080-solved-while-loop-help/ Share on other sites More sharing options...
trq Posted September 22, 2009 Share Posted September 22, 2009 You need to define a new $audio object on each iteration, at the moment, your only writing to the same instance. Link to comment https://forums.phpfreaks.com/topic/175080-solved-while-loop-help/#findComment-922757 Share on other sites More sharing options...
dennismonsewicz Posted September 22, 2009 Author Share Posted September 22, 2009 Sweet! that worked! Link to comment https://forums.phpfreaks.com/topic/175080-solved-while-loop-help/#findComment-922760 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.