Forum Moderators: coopster
$query_getAssignment = "SELECT empNo, projectID, period1, period2, period3, period4, period5, period6, period7, period8, period9, period10, period11, period12, projects.projectName FROM assignments LEFT JOIN projects USING (projectID) WHERE assignments.empNo =".$row_employeeList['EmpNo']. " ORDER BY assignments.projectID";
This properly grabs all of the information and repeats it throughout the table for the employee specified by $row_employeeList['EmpNo']. However it only works for the very first employee in the list. i.e. If I remove the first person in the list, it would display the correct information for person 2 (who is now number 1).
I would like to be able to select any employee from the dynamic drop down list and update the table based on that employee's information.
Thanks in advance for the help
$row_employeeList['EmpNo'] from? I think this is where your problems lies...
<select name="employeeName" id="employeeName">
<?php
do {
?>
<option value="<?php echo $row_employeeList['EmpNo']?>"<?php if (!(strcmp($row_employeeList['EmpNo'], $row_employeeList['name']))) {echo "selected=\"selected\"";}?>><?php echo $row_employeeList['name']?></option>
<?php
} while ($row_employeeList = mysql_fetch_assoc($employeeList));
$rows = mysql_num_rows($employeeList);
if($rows > 0) {
mysql_data_seek($employeeList, 0);
$row_employeeList = mysql_fetch_assoc($employeeList);
}
?>
</select>
<select name="employeeName" id="employeeName">
<?php
while ($row_employeeList = mysql_fetch_assoc($employeeList)) {
echo '<option value="'.$row_employeeList['EmpNo'].'" ';
echo (!strcmp($row_employeeList['EmpNo'], $row_employeeList['name']))? "selected >":">";
echo $row_employeeList['name'].'</option>';
}
?>
</select>
[b]<input type="submit" value="Get Information!" />[/b]
Now, unless you are using AJAX, this form must be submitted to the server before you can extract the data from the database.
Then on the action page, your query would then look something like this:
$query_getAssignment = "SELECT empNo, projectID, period1, period2, period3, period4, period5, period6, period7, period8, period9, period10, period11, period12, projects.projectName FROM assignments LEFT JOIN projects USING (projectID) WHERE assignments.empNo = '".[b]mysql_real_escape_string($_POST['employeeName'])[/b]."' ORDER BY assignments.projectID";