Jump to content

Checkbox Updating


kmark

Recommended Posts

Hi,

 

I have a page in my application where managers are assigned employees.  Currently you click on the managers name and that takes you to a page where all the employees are listed with a checkbox beside their name.  If the checkbox is checked then that employee is assigned to that manager using the code below (MSSQL database).

 

if(count($_POST['link'])) {
	$sql = "INSERT INTO tblAssignment (employeeID1, employeeeID2) (SELECT $id, ". implode (') UNION (SELECT '. $id .', ',  $_POST['link']) .")";
}

 

That is working fine

 

What i just realized now is that employees can be unassigned-unchecked (deleted from the assignment table) and I don't want to have duplicate entries either. What would be the best way to filter the checkboxes to make sure that if a box has been unchecked that the row gets deleted or if it stays checked that it does not get entered again?

Link to comment
Share on other sites

hmmmm, i guess what i'm trying to avoid is having to loop through all the employees and check if they are assigned or not and the run a query for each employee.

 

So what im thinking is would it be better if when the form is submitted all the assignments to that manager are deleted and the just run the one Insert query i have above?

 

I think this makes sense but let me know what you think.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.