@BIOSTALLNov 12.2010 — #I'm guessing you'll need to do something like this: (untested)
[code=php]if ($_POST) { // has the form been submitted
$insert_values = array(); // add the first entries to the query if they exist if ($_POST['subjectcode_1']!="" && $_POST['subjectname_1']!="") { array_push($insert_values, "('".$_POST['username']."', '".$_POST['subjectcode_1']."', '".$_POST['subjectname_1']."')") } // add the second entries to the query if they exist if ($_POST['subjectcode_2']!="" && $_POST['subjectname_2']!="") { array_push($insert_values, "('".$_POST['username']."', '".$_POST['subjectcode_2']."', '".$_POST['subjectname_2']."')") } // add the third entries to the query if they exist if ($_POST['subjectcode_3']!="" && $_POST['subjectname_3']!="") { array_push($insert_values, "('".$_POST['username']."', '".$_POST['subjectcode_3']."', '".$_POST['subjectname_3']."')") } // add the fourth entries to the query if they exist if ($_POST['subjectcode_4']!="" && $_POST['subjectname_4']!="") { array_push($insert_values, "('".$_POST['username']."', '".$_POST['subjectcode_4']."', '".$_POST['subjectname_4']."')") } // add the fifth entries to the query if they exist if ($_POST['subjectcode_5']!="" && $_POST['subjectname_5']!="") { array_push($insert_values, "('".$_POST['username']."', '".$_POST['subjectcode_5']."', '".$_POST['subjectname_5']."')") }
Note: the above assumes that your 'Name' field is called username and the subject code and subject names are called 'subjectcode_x' and 'subjectname_x' respectively where x is the row number.
Like I say I haven't tested the above but I hope it points you in the right direction.