records deleting before clicking delete

I have some checkboxes and a user is meant to click the checkboxes for the items they want to delete. However, at the moment it automatically deletes everything before the page even loads so you can't actually click on anything because there are no records as it deletes everything!

if (isset($_POST['Delete'])){
  foreach ($_POST['prodsizeid'] as $delete_id){
  $deleteSQL = sprintf("DELETE FROM sizes WHERE sizeid = $delete_id AND productid =%s",
  GetSQLValueString($_GET['ProductID'], "text"));
  $result = mysql_query($query, $test);

Open in new window

Who is Participating?
Tyler LaczkoCommented:
update your if to $_POST['delete'] == "your delete button value"

you also need to check is $_POST['prodsizeid']  is checked change your form from POST to GET and it will help you out.

after you have it working with GET change back to POST
jonofatAuthor Commented:
Sorted it out, thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.