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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:51:21+00:00 2026-05-13T14:51:21+00:00

Level: PHP Learner I’m stuck with a checkbox problem. I have a db that

  • 0

Level: PHP Learner

I’m stuck with a checkbox problem. I have a db that contains names and unique id numbers.

Using a query, I am pulling a selection of students and showing them to a user in an ultra simple HTML table on a form. Each row begins with a checkbox. The method is POST. So far, so good. My table looks like this:

+-----------+----------+----------+
|   SELECT  |    NAME  |    ID    |
+-----------+----------+----------+
|   []      |    John  |    2233  |
+-----------+----------+----------+
|   []      |    Susie |    5577  |
+-----------+----------+----------+

[-SUBMIT-]

My problem is that I cannot seem to make the checkbox associate with each record’s unique ID. Once the user has selected rows and clicked submit, the $_POST array remains empty.

None of my beginners books reference this specific issue. They go through the “regular” checkbox routines that don’t involve interacting with rows from a db. I also could not find an issue on Stackoverflow that addresses this. Also tried Google: plenty of stuff on checkboxes, but I couldn’t find any that helped me on this problem.

  • 1 1 Answer
  • 1 View
  • 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-13T14:51:22+00:00Added an answer on May 13, 2026 at 2:51 pm

    Edit: If your form doesn’t get more complex as you describe, take Doug Neiner’s approach, as it is way simpler. This approach is right if a table is likely to have a number of columns.

    I like to do it this way:

    Number the checkboxes sequentially (1 to 100) and add a hidden field connecting the row number to a real database ID:

    <input type="checkbox" name="row_1" value="checked">`
    <input type='hidden' name='row_1_id' value='2233'>`
    

    Store the total number of rows in another hidden field

    <input type='hidden' name='row_total' value='99'>

    Then, in the receiving script, iterate from 1 to the total number of rows using for, check whether this row was selected, and get the associated database ID:

    for ($i = 1; $i <= $number_of_rows; $i++)
    {
      if ($_POST["row_$i"] == "checked")
       {
         $database_id_unsafe = $_POST["row_{$i}_id"];
     ...
    

    the latter, of course, needs to be properly sanitized and escaped in case it is processed further.

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

Sidebar

Related Questions

I'm wonder upto what level of hadoop programming can be done using PHP or
I am using the following code: <?php $pattern = /(?<item>.*)\:(?<value>.*)(\{(?<flag>.*)_(?<level>.*)\})/i; $subject = item:value{L_300}; preg_match($pattern,
My level of knowledge so far is such that I have completed The Little
Is there free and good line-level profiler for PHP? I'm using xdebug and it's
I have a folder admin that has config.php, admin.php. I want to get navmenu.php
I have created a repository that contains a subfolder called 'subrepo'. I then created
I have made a Web page using jquery and php where all files are
Say, I have index.htm and routines.php. index.htm will call eventually call routines.php using JS
I have a simple query in DQL that selects 3 columns: $qb->select(c.zip_code, c.name, s.state)
Why is it that higher level languages (Javascript, PHP, etc.) don't offer data structures

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.