jseth
11-15-2010, 08:35 PM
I'm certain that this is easy.... for some one! I have an application which stores user skills for our employees. The user can log in and click on a menu item which will display (results from a query) their unachieved skills, with a check box, the intention of which it to have them check which skills they can perform.
I can make a checkbox form using values I already know, but I do not know how to to deal with the results of a query being the values. What I would like to have happen is that when a user checks one or more skill check boxes, the field "achieved" in the db would be set or updated to "Yes". Each skill has a unique user_skillID, so that is the field I am looking to "hook up" with its "achieved" field when the user checks the box. I have it going to a changeskillsrecord.php page, but I'm not really sure what to put in there either.
I hope someone can help me with this, I just can't seem to get my head around it! Currently, the query below displays all the skills that a user would have NOT achieved, for the Access 2007 topic.
<html>
<head>
<title>Microsoft Access 2007 Skills Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="Includes/si.css" rel="stylesheet" type="text/css" />
</head>
<body topmargin="5" leftmargin="0">
<table width="980" align="center" cellpadding = "0">
<td>
<tr>
<th align="center">
<b>Microsoft Access 2007 skills for
<?php
echo $_SESSION['fname'];
echo ' ';
echo $_SESSION['lname'];
echo ":";
?>
<br/><p>(If no skills appear, there are no skills for you to update.)</p>
</th>
</tr>
</td>
<tr>
<td>
<?php require 'Includes/topicsmenu.php'; ?><br />
</tr>
</td>
</table ><br />
<table width="800" align="center" border="1">
<td>
<tr>
<th>Skill ID</th>
<th>Skill Description</th>
<th>Select Achieved Skills</th>
</tr>
</td>
<?php
mysql_select_db($database_skills, $skills);
$query_MySkills = "SELECT user_skills.user_skillID, skills.topic, skills.skill, user_skills.tngdate, user_skills.achieved, users.username, DATE_FORMAT(`tngdate`,'%d-%b-%y') AS tngdate
FROM skills, users, user_skills
WHERE users.username = ('$username') AND users.userID=user_skills.userID AND user_skills.achieved != 'N/A' AND user_skills.achieved !='Yes'
AND user_skills.skillID=skills.skillID
AND skills.topic = 'Access'
ORDER BY topic, skill";
$MySkills = mysql_query($query_MySkills, $skills) or die(mysql_error());
//$row_MySkills = mysql_fetch_assoc($MySkills);
$totalRows_MySkills = mysql_num_rows($MySkills);
$result = mysql_query($query_MySkills, $skills);
while($row_MySkills = mysql_fetch_assoc($MySkills))
{
echo '<tr>';
echo '<td align="center">' . ($row_MySkills['user_skillID']).'</td>';
echo '<td align="left"> ' . ($row_MySkills['skill']). '</td>';
echo '<td <form method="POST" action="changeskillsrecord.php">
<p align="center"><input type="checkbox" name="user_skillID[]" value="$row_MySkills[user_skillID]">';
echo '</tr>';
}
?>
<br /><br />
<td>
<td>
<td>
<p align="center"><input type="submit" value="Select"></p>
</form>
</td>
</td>
</td>
</table>
</body>
</html>
I can make a checkbox form using values I already know, but I do not know how to to deal with the results of a query being the values. What I would like to have happen is that when a user checks one or more skill check boxes, the field "achieved" in the db would be set or updated to "Yes". Each skill has a unique user_skillID, so that is the field I am looking to "hook up" with its "achieved" field when the user checks the box. I have it going to a changeskillsrecord.php page, but I'm not really sure what to put in there either.
I hope someone can help me with this, I just can't seem to get my head around it! Currently, the query below displays all the skills that a user would have NOT achieved, for the Access 2007 topic.
<html>
<head>
<title>Microsoft Access 2007 Skills Listing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="Includes/si.css" rel="stylesheet" type="text/css" />
</head>
<body topmargin="5" leftmargin="0">
<table width="980" align="center" cellpadding = "0">
<td>
<tr>
<th align="center">
<b>Microsoft Access 2007 skills for
<?php
echo $_SESSION['fname'];
echo ' ';
echo $_SESSION['lname'];
echo ":";
?>
<br/><p>(If no skills appear, there are no skills for you to update.)</p>
</th>
</tr>
</td>
<tr>
<td>
<?php require 'Includes/topicsmenu.php'; ?><br />
</tr>
</td>
</table ><br />
<table width="800" align="center" border="1">
<td>
<tr>
<th>Skill ID</th>
<th>Skill Description</th>
<th>Select Achieved Skills</th>
</tr>
</td>
<?php
mysql_select_db($database_skills, $skills);
$query_MySkills = "SELECT user_skills.user_skillID, skills.topic, skills.skill, user_skills.tngdate, user_skills.achieved, users.username, DATE_FORMAT(`tngdate`,'%d-%b-%y') AS tngdate
FROM skills, users, user_skills
WHERE users.username = ('$username') AND users.userID=user_skills.userID AND user_skills.achieved != 'N/A' AND user_skills.achieved !='Yes'
AND user_skills.skillID=skills.skillID
AND skills.topic = 'Access'
ORDER BY topic, skill";
$MySkills = mysql_query($query_MySkills, $skills) or die(mysql_error());
//$row_MySkills = mysql_fetch_assoc($MySkills);
$totalRows_MySkills = mysql_num_rows($MySkills);
$result = mysql_query($query_MySkills, $skills);
while($row_MySkills = mysql_fetch_assoc($MySkills))
{
echo '<tr>';
echo '<td align="center">' . ($row_MySkills['user_skillID']).'</td>';
echo '<td align="left"> ' . ($row_MySkills['skill']). '</td>';
echo '<td <form method="POST" action="changeskillsrecord.php">
<p align="center"><input type="checkbox" name="user_skillID[]" value="$row_MySkills[user_skillID]">';
echo '</tr>';
}
?>
<br /><br />
<td>
<td>
<td>
<p align="center"><input type="submit" value="Select"></p>
</form>
</td>
</td>
</td>
</table>
</body>
</html>