Updating a database with a loop/array/foreach?

Awesome thanks that really helped!

Here is the working code:

<input type="text" name="dates[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['dates']; ?>" class="rates" />
   <input type="text" name="night[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['night']; ?>" class="rates" />
   <input type="text" name="week[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['week']; ?>" class="rates" />
   <input type="text" name="month[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['month']; ?>" class="rates" />
   <input type="text" name="min[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['min']; ?>" class="rates" />
   <input type="text" name="rank[<?php echo $e2['id']; ?>]" maxlength="20" value="<?php echo $e2['rank']; ?>" class="rates" />
$sql3 = "UPDATE ratestable
					SET dates=?, night=?, week=?, month=?, min=?, rank=? 
					WHERE id=?";
			$stmt3 = $db->prepare($sql3);
			if(count($_POST['rank']) > 0)
			{
			  foreach($_POST['rank'] AS $key => $val)
			  {
				  $stmt3->execute(array(
									   $_POST['dates'][$key],
									   $_POST['night'][$key],
									   $_POST['week'][$key],
									   $_POST['month'][$key],
									   $_POST['min'][$key],
									   $val, 
									   $key 
									   
									   ));
			  }}
			$stmt3->closeCursor();