Help with multiple update form/script

Hi there,

Just wondering if someone could help me with a script I’m working on. Basically I want it to display some records, one field is updatable by text field, then when the user clicks submit it updates all the records.

Here you can see what I mean along with the test data.

Problem: For some reason I always get a blank entry at the top. I would also like to try and make the script update without selecting the radio boxes before submit. The form works fine otherwise and updates the editable textfield in the database.

Help with getting just the blank entry to stop showing would be great though, thanks very much.


<?php
include "DB Connection/connect.php";
$result = mysql_query("SELECT * FROM records order by ordering asc",$connect);
 
if (isset($_POST['selectdelete'])) //select the radio button delete, then submit
{
	 $ids_to_delete = join(',' , $_POST['chkitemdel']); //sql for deleting follows join 
	 mysql_query("DELETE FROM records WHERE id IN ($ids_to_delete)");
	header('Location: test.php'); 
}
elseif (isset($_POST['selectupdate'])) //select the radio button update, then submit
{
for ($i = 0; $i < count($_POST['uniqueid']); $i++) // if it finds a id, then loop through and update
{
	mysql_query("UPDATE records Set ordering = '".$_POST['txtfield'][$i]."' Where id = '".$_POST['uniqueid'][$i]."'");
header('Location: test.php'); 
}
}
?>
<form method="POST" name="form1" id="form1">
 
		 <table border="0">
 
			<?php 
 
do // This is the a loop to repeat all of the records for this particular recordset.
 
{ 
 
?> 
 
			<tr> 
			 <td align="center" valign="middle">Delete?<br>
				<input name="chkitemdel[]" type="checkbox" id="chkitemdel[]2" value="<?php echo $myrow['id']; ?>"> <!-- This checkbox allows you to delete entries-->
			 </td>
 
	 <td align="center" valign="middle">ID:<br>
			 <?php echo $myrow['id']; ?>
			 </td>
 
	 <td align="center" valign="middle">Question<br>
			 <?php echo $myrow['question']; ?>
			 </td>
			 <td colspan="2" align="center" valign="middle"> 
				<textarea name="txtfield[]" cols="30" rows="3" id="txtfield[]"><?php echo $myrow['ordering']; ?></textarea> <!-- this is the text you want to update -->
				<input name="uniqueid[]" type="hidden" id="uniqueid[]" value="<?php echo $myrow['id']; ?>"> <!-- this is the primary key for the record you wish to update.-->
	 </td> 
			</tr>
 
			<?php 
 
} 
 
 
 
while ($myrow = mysql_fetch_array($result)); 
 
?>
 
			<tr align="center" valign="middle"> 
			 <td colspan="2">
	 <input type="radio" name="selectdelete" value="1">
			 Delete Record 
			 <input name="selectupdate" type="radio" value="2">
			 Update Record
	 </td>
			 <td width="21%">
	 <input type="submit" name="Submit" value="Submit">
	 </td>
			</tr>
		 </table>
 
		</form>