How to make a button submit a specific form, when using a while loop to create forms

hey guys, I am using a while loop to store my query results in forms, which I can make editable. When editing the data in the forms, I have a button under each one, but when I edit a form and press submit it doesn’t work, unless I edit the last form created, so obviously there is a problem doing this while looping.

Here is my query results loop:

while($row = sqlsrv_fetch_array($stmt))
			$forename = $row['Forename'];
			$surname = $row['Surname'];
			$dob = $row['Date_of_Birth'];
			$school = $row['School'];
			$medical = $row['Medical_Notes'];
			$allergies = $row['Allergies'];
			$notes = $row['Notes'];
			$cid = $row['Child_ID'];
			$children.= '<fieldset class="childrenForm">

						<input type="text" name="cid" value=" '.$cid.'" readonly="readonly"/><br/><br/> 
						<input type="text" name="name" value=" '.$forename.'" '.$ro.'/><br/><br/> 
						<input type="text" name="surname"	value="'.$surname.'" '.$ro.'  /><br/><br/>
						<label>Date of Birth:</label> 
						<input type="text"	name="dob" value="'.$dob.'" '.$ro.'/><br/><br/>
						<input type="text" name="school" value="'.$school.'" '.$ro.' /><br/><br/>
						<input type="text" name="medical" value="'.$medical.'" '.$ro.' /><br/><br/>
						<input type="text" name="allergies" value="'.$allergies.'" '.$ro.' /><br/><br/>
						<input type="text" name="notes" value="'.$notes.'" '.$ro.'/><br/><br/>

						<input id="subButt" name="editChildren" type="submit" value="Save"/>

And here is the SQL to update the children table:

if(isset($_POST['editChildren']) && isset($_SESSION['fid']))
	$sql = "UPDATE Children SET Forename=?, Surname=?, Date_of_Birth=?, School=?, Medical_Notes=?, Allergies=?, Notes=? where Family_ID =? AND Child_ID=? ";
	$params = array($givenName, $familyName, $dob, $school, $medical, $allergies, $notes, $_SESSION['fid'], $childID);
	//Check SQL Query
	$stmt = sqlsrv_query( $conn, $sql,$params, array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
		die('An error has occured with your registration. If this is an indeliberate occurance,
			 please report this to us through the contact us page with details of the error.');
		header('Location: fam_children.php');

I think the problem is that I need to create a separate button for each form, I am not sure, if anyone can help me out that would be fantastic!


Hint: You can have more than one <form> tag on a page. A submit button will fire only the form which it is inside.

Hey Starlion, I was concentrating so much on the PHP, I left my HTML out in the rain. OOPS! I never had the form tags around the the looped form inputs, right enough. Sometimes I swear I cannot do any easy stuff, only hard stuff!

Thank you!