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 7648499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:43:52+00:00 2026-05-31T10:43:52+00:00

I am pulling data down from a MySQL table and loading it into a

  • 0

I am pulling data down from a MySQL table and loading it into a form for editing(updating) a record. Everything is working great until I come the the check boxes. The checkboxes in the form accurately reflect the values in the appropriate columns in the db. But when the person editing changes the checkbox in the edit form it does not pass the data to the database. I have read a ton of checkbox Q&A on stack overflow but don’t seem to find what I am looking for. Sorry if this is a redundant Question. Here is the code.

<label for="amenities-beach">
<input class="choose" name="amenitiesB" id="amenities-beach" type="checkbox" 
value="<?php echo $row1["amenitiesB"]; ?>" 
<?php echo $row1["amenitiesB"] ? 'checked="checked"' : ''; ?> /> 
&nbsp;Close to Beach</label>

Where amenitiesB in:

value="<?php echo $row1["amenitiesB"]; ?>

is what has been returned from the DB with a SELECT statement with:

 $row1 = mysql_fetch_array($result); 

But when I change the value in the form and submit it nothing is passed to the variable in the UPDATE statement. Any idea what I am missing? I have 6 of these checkboxes,amenitiesB, amenitiesK, amenitiesS, amenitiesP, amenitiesF, and preferred all with the same code. Any help would be appreciated.
Thank You,
Dave

Ok here is the code: Everything else in the form updates fine. I attempt to pass it to:
$amenitiesB = $_POST[‘amenitiesB’];
then I put it into the update statement
Hotels.amenitiesB='”.$amenitiesB.”‘,
My UPDATE statement is,
$query=”UPDATE Hotels
JOIN surfcup_Rates ON Hotels.id = surfcup_Rates.hotelid
SET Hotels.hotel='”.$hotel.”‘,
More columns, then

Hotels.amenitiesB='".$amenitiesB."', 
Hotels.amenitiesB='".$amenitiesK."',
Hotels.amenitiesB='".$amenitiesS."',
Hotels.amenitiesB='".$amenitiesP."',
Hotels.amenitiesB='".$amenitiesF."',
Hotels.amenitiesB='".$preferred."',    

More columns then:

WHERE Hotels.id='".$id."'";
  • 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-05-31T10:43:53+00:00Added an answer on May 31, 2026 at 10:43 am

    The problem you have comes because when a checkbox is unchecked, by default its data is not transmitted to your PHP, and that’s why you have problems by having the UPDATE query parameter empty.
    So before your update statement you should have:

    $fieldenabled=(bool)(isset($_POST['CHECKBOXNAME']) ? TRUE : FALSE;
    

    And call your UPDATE query with that.

    EDIT: Of course you can change $_POST with $_GET depending on the sending method of the <form>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pulling data from one table, called analyzedCopy, and using it to over-rite
I am working on an iPhone App where I am pulling data from an
I am pulling data out of an old-school ActiveX in the form of arrays
I am pulling data from Twitter's API and the return date is UTC in
I have the following function that is pulling data from a database. The ajax
I have an INSERT query that is pulling data from two tables and inserting
Background: I'm building a small application that will be run daily, pulling data from
My code is pulling from a data cells that lists multiple file paths and
I'm working on a query where I pull data from multiple tables using left
I have an iPhone app which is pulling just about all it's data from

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.