records deleting before clicking delete

Posted on 2011-05-12
Last Modified: 2012-05-11
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

Question by:jonofat
    LVL 10

    Accepted Solution

    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

    Author Comment

    Sorted it out, thanks.

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now