Multiple MySQL inserts into database

hello all.

I have this code which i use to loop through an array and it works great

here it is.
NOTE: It loops through an array and INSERTS each item into it individually. $item_id is created by mysql_insert_id().


		foreach ($form['material'] as $id){
			$insertQuery = "INSERT INTO cms_item_material (item_id, material_id)
			VALUES ('$item_id', '$id')";
			if (!$result = $connector->query($insertQuery)){
				$warnings[] =  'material '.$id.'';
			}
		}

Its not so much as a problem but i was wondering would this way be better as it only outputs one error (if there is one) instead of and array error list.

NOTE: not sure if this the correct syntax but its for the idea.


           $insertQuery = "INSERT INTO cms_item_material (item_id, material_id) VALUES "
		$numberOf = count($form['material']);
		$count = 0;
		while ($count <= $numberOf)
			$insertQuery .= '(\'.'$item_id.'\', \''.$form['material']['$count'].'\')'
			if($count != $numberOf){
				$insertQuery .=',';
			}
		$count ++;
		}
		
		if ($result = $connector->query($insertQuery)){
		return 'items added';
		}