Well I have 3 Database tables I am working off of

1 is for Users, It contains IDs, Names, ect, ect

1 is for the skills they are trained in, it has 2 columns, One for skill_id and one for Description (portal_userSkills)

The last table is a joiner it joins IDs, that appear more than once, and the skills. There may be 5 or 6 of the Same ID with different Skills. (portal_userSKill)

Here is the code so far

<?php
$searchvalue_Recordset1 = "";
if (isset($_GET['searchvalue'])) {
  $searchvalue_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['searchvalue'] : addslashes($_GET['searchvalue']);
}
$field_Recordset1 = "";
if (isset($_GET['field'])) {
  $field_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['field'] : addslashes($_GET['field']);
}
if ($searchvalue_Recordset1 <> "") {
$case=$query_users = sprintf("SELECT * FROM portal_users WHERE %s LIKE CONVERT( _utf8 '%s' USING latin1 ) 
COLLATE latin1_swedish_ci", $field_Recordset1,$searchvalue_Recordset1);
}
else{
	$case=$query_users = sprintf("SELECT * FROM portal_users WHERE active = '1' ORDER BY lname ASC");
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">



	<head>
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Expires" content="-1" />
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<link href="../../styles/main.css" rel="stylesheet" type="text/css" />
		<title>Test Employees</title>
		<style type="text/css">
.trainItem {color:black; background-color: #C0C0C0; text-align: center; float: bottom; font: 16px bold Arial; width: 250px; border-bottom: 1px solid black; border-right: 1px solid black; padding: 2px;}
.getLeft {float:left; margin: 3px; padding 2px; border: 1px solid black;}
.skillItem {
font: 9pt Calibri black;
float: left;
margin-left: 3px;
}
.allSkill {
float:left;
padding-left: 4px;
padding-top: 1px;
padding-bottom: 1px;
font: 9pt Calibri black;
text-align: center;
}
.leftUpdate {
width: 30px;
height: 20px;
}
.wrap {
float: left;
}
</style>
</head>

	<body><div class="subsection_navbar">
		<h1>TEst Employees</h1>
	</div>	
	<center><div class="wrap"><table width="90%">
	 <tr align="center">
		<td width="100%"><h4>Trained In Key</h4></td>
	 </tr>
	 <tr><td><div class="getLeft"><div class="trainItem">Sp - Spanish</div><div class="trainItem">StTS - Staples Tech</div><div class="trainItem">StCS - Staples CS</div><div class="trainItem">RSTS - RadioShack Tech</div><div class="trainItem">RSCS - RadioShack CS</div><div class="trainItem">COMP - CompUSA</div></div><div class="getLeft"><div class="trainItem">CC - Circuit City</div><div class="trainItem">HDR - Home Depot Reg</div><div class="trainItem">HDLA - Home Depot Large App</div><div class="trainItem">NFM - Nebraska Furniture Mart</div><div class="trainItem">GE FL - GE Front Line</div><div class="trainItem">GEFACT - GE Factory</div></div><div class="getLeft"><div class="trainItem">MAY - Maytag</div><div class="trainItem">WHRL - Whirlpool</div><div class="trainItem">CAN - Canada Lines</div><div class="trainItem">EZCS - EasyTech CS</div><div class="trainItem">Online - Remote</div><div class="trainItem">LS - Lending Solutions</div></div></td></tr></table></center>
        &nbsp;
<table width="100%">
	<tr align="center">
		<td width="33%"><a href="database.php">View Users</a></td>
		<td width="33%"></td>
	  <td width="33%"><a href="input_user.php">Add User</a> </td>
	</tr>
</table><br />

<table width="90%"  border="0" align="center" cellpadding="2" cellspacing="0">
	<tr class="header1">
		<td><div align="center"></div>			
		<div align="center"><strong>Total Users: <?php echo $totalRows_users;?></strong></div></td><td><div class="leftUpdate" align="right"><input type="submit" name="Submit" value="Update"></div></td>
  </tr>
</table>
<table width="90%"  border="1" align="center" cellpadding="2" cellspacing="0">
	<tr class="header">
		<th scope="col" width="320px">Last Name</th>
		<th scope="col" width ="320px">First Name</th>
		<th scope="col" width="100%">Trained / Not Trained</th>
<form name="updateSkills" method="post" action="<? echo $_SERVER['REQUEST_URI']; ?>"> 
	</tr>
  <?php do { ?>
  <tr class="normal">
		<td><div align="center"><a href="updateuser.php?id=<?php echo $row_users['user_id']; ?>"><?php echo $row_users['lname']; ?></a></div></td>
 		<td><div align="center">&nbsp;<?php echo $row_users['fname']; ?></div></td><td>
<?php 

$query_skills = "SELECT portal_userSkills.Desc FROM portal_userSkill NATURAL JOIN portal_userSkills NATURAL JOIN portal_users WHERE user_id = " .$row_users['user_id'];
$skills = mysql_query($query_skills, $TEST_MySQL_Database) or die(mysql_error());
$row_skills = mysql_fetch_assoc($skills);
$totalRows_skills = mysql_num_rows($skills);

$query_all = "SELECT * FROM portal_userSkills";
$all = mysql_query($query_all, $TEST_MySQL_Database) or die (mysql_error());
$row_all = mysql_fetch_assoc($all);
$totalRows_all = mysql_num_rows ($all);
$rows =mysql_fetch_array($all);

do {  
?>
<div class="allSkill">
<input type="hidden" value="<?php echo $row_users['user_id']; ?>" name="id[]">
<input type="checkbox" id="Desc" name="<?php echo $row_all['Desc']; echo $row_users['user_id'];
$row = mysql_fetch_array($skills); 
$num_skills = mysql_num_rows($skills); 
if ($row_skills['Desc'] == $row_all['Desc'])  { 
echo "\" checked >"; 
}else{
echo "\">";
} 
echo $row_all['Desc']."</div>"; 
}

 while ($row_all = mysql_fetch_assoc($all));
?>
</td></tr>

  <?php } while ($row_users = mysql_fetch_assoc($users)); ?>
</table>
</div><center><div class="leftUpdate"><input type="submit" name="Submit" value="Update"></div></center>

<?php 

if($Submit)
{ 
	
} 

if($result1){ 
header("location:update_skill.php"); 
} 
mysql_close(); 
?>


	</body>
</html>
<?php
mysql_free_result($users);
?>

So there is my code, It displays all my agents and all 19 skills, plus if they are already in a skill the checkbox is already checked.


I need a little help with the finishing of the Insert and Do not Insert if the user_id and skill_id are both already in the Table "portal_userSkill"

Any Help is GREATLY Appreciated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.