Jump to content

[SOLVED] while loop help


dennismonsewicz

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.