Bagaimana kalau Anda menyiapkan pernyataan di luar loop, lalu ikat nilai di dalam loop dan jalankan.
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$roll = $_POST['roll'];
$sql = "UPDATE student SET name=:name WHERE roll=:roll";
$query = $con->prepare($sql);
foreach($roll as $key => $n){
$query->bindParam(':roll', $n[$key]);
$query->bindParam(':name', $name[$key]);
$query->execute();
}
}