I think the easiest way you could do it is to have the <form> tag within the loop, so effectively each input field and each button is in its own form, so only those values will be set, so you would have:
?>
<table>
<?
while (loop)
{
?>
<form name=myform action=<?=$PHP_SELF?>?ID=<?=$mydata?>>
<td><input type="text" name="mydata" value=<?$array[data]?>></td>
<td><input type="submit" value="edit" name="submit"></td>
</form>
<?
}
You might notice that i haven't used any echo statements, thats because for any reasonable lenght of html output its better to escape from php (just using a closing ?> ) type html, then back into php when neccessary (using <?). The <?=$var?> is a shortended way of saying <? echo $var ;?>