RyanSF07 Posted June 4, 2009 Share Posted June 4, 2009 Hi Guys I want to be able to DELETE "assignments" from the Scores table WHERE such and such AND something else. Is that possible? Code below -- if ($_GET[delete_assignment_id]) { $sql3 = "DELETE FROM scores WHERE scores.assignment_number = '$_GET[delete_assignment_id]' AND registered_users.id = $_SESSION[user_id]"; if (mysql_query($sql3)) { $content .= "<h2>The scores have been deleted</h2> <h2><a href='my_account_view_scores.php'>Please click here to see the updated list.</a></h2>"; } else { $content .= "<p>The scores could not be deleted due to a system error.</p>"; } Quote Link to comment Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 <?php if (isset($_GET['delete_assignment_id'])) { $delete_assignment_id = (int) $_GET['delete_assignment_id']; $sql3 = "DELETE FROM `scores` WHERE `scores`.`assignment_number` = $delete_assignment_id AND `registered_users`.`id` = $_SESSION['user_id']"; if (mysql_query($sql3)) { $content .= "<h2>The scores have been deleted</h2> <h2><a href='my_account_view_scores.php'>Please click here to see the updated list.</a></h2>"; } else { $content .= "<p>The scores could not be deleted due to a system error.</p>"; } } That's how you want the code, but the following won't work DELETE FROM `scores` WHERE `scores`.`assignment_number` = $delete_assignment_id AND `registered_users`.`id` = $_SESSION['user_id'] The `registered_users`.`id` = $_SESSION['user_id'] part is checking a different table; 1. why would you want to 2. it can't be done like that Quote Link to comment Share on other sites More sharing options...
RyanSF07 Posted June 4, 2009 Author Share Posted June 4, 2009 Thank you -- the problem I see is that different teachers will inevitably call their assignments the same number. John's assignment is #14, but so is Kim's. Thus deleting all assignments numbered "14" will delete other teacher's assignment's scores. So I wonder if there is a was to say only delete the assignment scores for "this" teacher -- as in, registered_users.id = $_SESSION[user_id] Possible? Quote Link to comment Share on other sites More sharing options...
gevans Posted June 4, 2009 Share Posted June 4, 2009 Store the users id in the assignments table, then reference that. as long as it is in the same table its fine Quote Link to comment 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.