动态变量PDO

I'm using PDO to update my database. I'm using a loop to display the IDs and values from input boxes. Right now I have:

foreach ($data as $row): ?>
    <form action="" method ="post">
        <input type="text" name="Name[<?=$row['ID']?>]">
        <input type="hidden" name="NameID[<?=$row['ID']?>]" value="<?=$row["ID"]?>">
        <input type="submit" class="button" value="Submit" name="NameEnter[<?=$row["ID"]?>]">
    </form>
<?endforeach?>

Which obviously outputs something like Name[1], Name[2], etc.

For my PDO when I go to update it how do I get

$name = $_POST["Name"];
$ID = $_POST["ID"];
if(isset($_POST['NameEnter'])) {
$update = $db->prepare("UPDATE Table SET Name = ? WHERE ID = ?");
$update->execute(array($name,$ID));
}

It keeps outputting the value of ARRAY instead of the actually typed in value. I assume it has to do with $name being looped as the same thing?

As each time round that loop you create a seperate form you dont need the complicated naming convention for your input fields

foreach ($data as $row): ?>
    <form action="" method ="post">
        <input type="text" name="Name">
        <input type="hidden" name="ID" value="<?=$row["ID"]?>">
        <input type="submit" class="button" value="Submit" name="NameEnter">
    </form>
<?endforeach?>

Then its a simple piece of code with easy to figure out field names in the $_POST array.

if(isset($_POST['Name'], $_POST['ID'])) {
    $update = $db->prepare("UPDATE Table SET Name = ? 
                            WHERE ID = ?");
    $update->execute(array($_POST["Name"], $_POST["ID"]));
} else {
    echo 'Missing input';
}

Check out bindValue

Syntax: $stmt->bindValue(':placeholder', $value, PDO::PARAM_TYPE);

$update = $db->prepare("UPDATE Table SET Name = :name WHERE ID = :id");
$update->bindValue(':name', $name, PDO::PARAM_STR);
$update->bindValue(':id', $id, PDO::PARAM_INT);
$update->execute();