Problem with drop down menus

Discussion in 'PHP' started by karl_murphy, Nov 20, 2009.

  1. #1
    Hello there,

    I am struggling with a problem I'm experiencing with drop down menus and I would really appreciate any help. The code I am working on is as follows:

    foreach($sub_codes as $a_code)
    {				
    	$sql2 = "SELECT MD_CL_Subject, MD_Attainment, IF_TA_SubCode, IF_TA_ID, CS_CL_SubjectCode 
    FROM `MainData`, `ClassStudent`, `ifile_Target`
    WHERE MainData.MD_PU_AdNo = ClassStudent.CS_PU_AdNo
    AND MainData.MD_PU_AdNo = ifile_Target.IF_TA_PU_AdNo
    AND ClassStudent.CS_PU_AdNo = ifile_Target.IF_TA_PU_AdNo
    AND MainData.MD_CL_SubjectCode = ClassStudent.CS_CL_SubjectCode
    AND MainData.MD_CL_SubjectCode = ifile_Target.IF_TA_SubCode
    AND ClassStudent.CS_CL_SubjectCode = ifile_Target.IF_TA_SubCode
    AND MainData.MD_CL_ClassName = ClassStudent.CS_CL_ClassName
    AND ClassStudent.CS_CL_SubjectCode = '" . $a_code . "' 
    AND MD_Semester = '" . $active_check . "'
    AND MD_PU_AdNo = '" . $adno . "'
    ORDER BY MD_CL_Subject ASC";
    
    include("?????????????");
    														
    while ($row2 = mysql_fetch_assoc($rst2))
    {									echo "<tr>";
    									echo "<td align = 'left'><span class = 'style19'>" . $row2['MD_CL_Subject'] . "</span></td>";
    									echo "<td><span class = 'style19'>" . $row2['MD_Attainment'] . "</span></td>";
    									echo "<td>" . $row2['IF_TA_ID'];
    									echo "<td><select name = 'target' value = '$target'>";
    										echo "<option value = '1'>1</option>";
    										echo "<option value = '2'>2</option>";
    									echo "</select>";
    									echo "</td>";
    									echo "<input type = 'hidden' name = 'target_id' value = '" . $row2['IF_TA_ID'] . "' />";
    									?>
    									<td align = "center">
    										<input type = "submit" name = "submit_target" value = "Save Target Grade" onclick = 'javascript: return confirm("Are you sure you want submit this order?")' />	
    									</td>
    							<?php //}
    							}	
    						}	     
    						echo "</tr>";
    PHP:
    What this code does is create a form for a student with all of their subject and grades for each subject with a drop down box for them to select a Target grade to aim for. Basically the problem I am experiencing is that no matter which submit button I press the 'target_id' printed off is always that of the last row in the table.

    Any help with this matter would be greatly appreciated.

    Regards,

    Karl.
     
    karl_murphy, Nov 20, 2009 IP