Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:40:10+00:00 2026-06-11T19:40:10+00:00

I have a form that allows engineers to be added to a job by

  • 0

I have a form that allows engineers to be added to a job by checking checkboxes which works fine. However, I would like the user to remove an engineer by unchecking their checkbox on another form.

The table (a many to many table) has 3 columns id_ce (the primary key), call_ce (foreign key) and engineer_ce (foreign key). I would like the form to check if a checkbox is empty and if it is check to see if there is an entry in the table with the call_ce and engineer_ce and delete it if it exists but I’m failing miserably.

This is what I have so far…

foreach($_POST['engineer'] as $engineer_id){
    if(!isset($_POST['engineer'])){
        $sql = "SELECT * FROM calls_engineers WHERE call_ce = '$diary_id' AND engineer_ce = '$engineer_id'";
        $result = mysql_query($sql)or die(mysql_error());
        if(mysql_num_rows($result) > 0){
            $sql = "DELETE FROM calls_engineers WHERE engineer_ce = '$engineer_id'";
            $result = mysql_query($sql)or die(mysql_error());
        }   
    }
}

I suspect the problem may be something like the checkboxes that aren’t checked don’t post so they aren’t going through the foreach loop but I’m not sure of another way of doing it.

Any help will be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:40:11+00:00Added an answer on June 11, 2026 at 7:40 pm

    You can put on page a hidden field with engineer ids. Say, it will be called engineer_on_page

    Now you can

    foreach($_POST['engineer_on_page'] as $engineer_id) {
         if(!in_array($engineer_id, $_POST['engineer'])){
              //do delete here
         }
    }
    

    I expect that checkboxes looks similar to this:

    <input type="checkbox" name="engineer[]" value="[engineer_id]"/>
    

    and hidden field

    <input type="hidden" name="engineer_on_page[]" value="[engineer_id]"/>
    

    Also you may specify checkbox field like this:

    <input type="checkbox" name="engineer[[engineer_id]]" value="[engineer_id]"/>
    

    where [engineer_id] is actual id (1, 2,3 etc)

    In second case you may use

         if(!isset($_POST['engineer'][$engineer_id])){
              //do delete here
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a form that allows users to upload multiple images, which are
I have a form that allows users to view some terms and conditions, which
I have a form that allows users to upload text AND a file. However,
I have a form that allows users to paste input, like on StackOverflow. But
I have a form that allows me to enter a user into my database.
I have a form that allows a user to import a spreadsheet. This spreadsheet
I have a form that allows users to enter a date of birth: ie:
I have a personal details form that allows you to enter a certain number
I have a TextBox in a Windows Form that allows a user to enter
I have a longish form that scrolls vertically and also allows editing records. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.