I am creating a "Talent Review" application whereby senior leadership in the company can rate their direct reports. The page has a database driven list of "Competencies" and each competency has a drop down list that displays a possible rating of 1 through 5.
The trouble is, I not only need the ratings sent to the action page but I also need "CompetencyID" and "EmplID" sent to the action page too. CompetencyID comes from the query shown below, EmplID comes to this page as a URL variable.
To say it another way, for each Rating, I also need the EmplID and CompetencyID sent to the action page. Can someone tell me how I can modify my existing code below to accomplish this? Thanks very much.
---------Code
<?php
// include configuration file
include('config.php');
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "SELECT CompetencyID, CompetencyName, SkilledDefinition
FROM LTRCOMPETENCY";
$result = mysql_query($query) or die("ERROR: $query.".mysql_error());
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
echo "<form method = post action = 'processRatings.php'>";
// yes
// print them one after another
echo "<div align='center'>";
echo "<table cellpadding=10 border=1 id=reg width=780>";
echo "<tr>";
echo "<td><strong> </strong></td>";
echo "<td><strong>Competency</strong></td>";
echo "<td><strong>Performance Criteria</strong></td>";
echo "<td><strong>Rating</strong></td>";
echo "</tr>";
//set a counter
$i=1;
while($row = mysql_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$i++."</td>";
echo "<td>".$row['CompetencyName']."</td>";
echo "<td align='left'>".$row['SkilledDefinition']."</td>";
echo "<td>
<select name='Rating[]'>
<option value=1>1 - Not at all</option>
<option value=2>2 - To some extent</option>
<option value=3>3 - To a moderate extent</option>
<option value=4>4 - To a considerable extent</option>
<option value=5>5 - To a great extent</option>
</select>
</td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan=4><input type = submit name = submit value=Submit></td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo '</form>';
}
else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
?>