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

  • Home
  • SEARCH
  • 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 8519829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:21:44+00:00 2026-06-11T06:21:44+00:00

I have a form that allows the user to add or remove users from

  • 0

I have a form that allows the user to add or remove users from a job by using checkboxes. At the moment the engineer’s names etc are stored in a table called ‘users’ and they are identified by their user type, engineers. The checkboxes on the form are created by using a while loop to display a mysql query. This is done so that new users can be added to the database via a webpage at a later date and their name will automatically be added to the list of available engineers. To add an engineer to a job their name is simply ticked and the form submitted.

This works well but I would like the user to be able to add or remove users by checking and unchecking boxes on another form but I can’t think for the life of me how to do this.

The users assigned to a job are stored in a many-to-many table called calls_engineers which has 3 fields

id_ce (unique id)
call_ce (id of job, a foreign key)
engineer_ce (id of engineer, a foreign key)

The engineer_ce is the users primary key in the ‘users’ table which is ‘id’.

The code I have so far is…

<?  $sql = "SELECT * FROM calls_engineers WHERE call_ce = '$diary_id'";
      $result = mysql_query($sql) or die(mysql_error());
      $row2 = mysql_fetch_array($result);
      $sql = "SELECT * FROM users WHERE type = 'engineer' ORDER BY first_name";
      $result = mysql_query($sql) or die(mysql_error());
      while ($row = mysql_fetch_array($result)){ ?>
          <div style="width:70px; float:left">
              <? 
                  if($row2['engineer_ce'] == $row['id']){
              ?>
              <input type="checkbox" name="engineer[]" checked="checked" value="<? echo $row['id']; ?>" />
              <? echo '   '.$row['first_name']; 
              } else { ?>
                  <input type="checkbox" name="engineer[]" value="<? echo $row['id']; ?>" />
              <? echo '   '.$row['first_name'];
              }?>
          </div>
  <?
      }

  ?>

All this does is create checkboxes for each user which is an engineer but it doesn’t check them if the user is assigned to the job.

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-11T06:21:46+00:00Added an answer on June 11, 2026 at 6:21 am

    You never loops the calls_engineers table. Using

    $row2 = mysql_fetch_array($result);
    

    Will not actually find all assignments for the engineer. Now check every single engineer if this is included in current job:

    <?  
    
      $sql = "SELECT * FROM users WHERE type = 'engineer' ORDER BY first_name";
      $result = mysql_query($sql) or die(mysql_error());
      while ($row = mysql_fetch_array($result)){ ?>
    
          <div style="width:70px; float:left">
              <input type="checkbox" name="engineer[]" <? 
                  $result2 = mysql_query("SELECT * FROM calls_engineers WHERE call_ce = '".mysql_real_escape_string($diary_id)."' AND engineer_ce = ".$row['id']);
                  if(mysql_num_rows($result2) > 0) echo 'checked="checked"';
                 ?> value="<? echo $row['id']; ?>" />
              <? echo '   '.$row['first_name']; ?>
          </div>
    
      <? } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bound form in microsoft access that allows a user to add
I have a form that allows a user to add an unlimited number of
I have a form I'm working with that allows the user to continually add
I have a form that allows the user to add as many upload forms
I have a form (will add form validation later) that allows the user to
I have a page that allows the user to add and remove text fields
I have a form that allows the user to add information an their leisure.
I'm using ASP.Net/C# and I have a form that allows people to add information
I have a form that allows the user to add more form fields if
I have a product registration form that allows the user to add additional product

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.