kmark Posted June 12, 2008 Share Posted June 12, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/109950-checkbox-updating/ Share on other sites More sharing options...
paulman888888 Posted June 12, 2008 Share Posted June 12, 2008 can you add a joined colunm? when joined a manerger joined = 1 else 0 Something like if joined = 1 then {code here saying already joined} else {Code here saying how to join} Thats used rough. Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/109950-checkbox-updating/#findComment-564229 Share on other sites More sharing options...
kmark Posted June 13, 2008 Author Share Posted June 13, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/109950-checkbox-updating/#findComment-564766 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.