When you submit the form, the entire page gets processed again, which means that $row['name'] will have a different value, since you're doing it randomly.
Make the name of the form field (of which you have two, you only need it once), something like id, whatever your primary key is. Then for the value of the hidden input you'd do $row['id'].
Yes, you were right, I apologize. The original way he has it is checking for the literal string - but changing it to your way won't work, because the value of $row['name'] will likely be different, due to the random factor.