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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:23:02+00:00 2026-05-15T06:23:02+00:00

Currently, my checkboxes are built by a static array: $choices = array( ‘key_1’ =>

  • 0

Currently, my checkboxes are built by a static array:

$choices = array(
   'key_1' => 'Name 1',
   'key_2' => 'Name 2',
    ...
   'key_n' => 'Name n');

<? foreach (@choices as $key => $choice) {
      echo "<input type="checkbox" name='keys[]' value='$key'/> $choice <br />";
   } ?>

and I access the return values by:

$_POST['keys']

What if I want the $choices array to be build from table data? How can I build a PHP array (which is good for building checkbox choices) from a table? Thanks

  • 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-15T06:23:03+00:00Added an answer on May 15, 2026 at 6:23 am

    Well, you could try this:

    $choices = array()
    $query = mysql_query("SELECT field1, field2 FROM ...");
    if (mysql_num_rows($query))
    {
        while ($row = mysql_fetch_array($query))
        {
            $choices[$row['field1']] = $row['field2'];
        }
    }
    

    Now $choices contain what you need.

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

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Basic idea is to build an index as a list… May 16, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer I think it's generally best to avoid the use of… May 16, 2026 at 10:17 am
  • Editorial Team
    Editorial Team added an answer We'd need to know more about the nature of the… May 16, 2026 at 10:17 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Currently it just displays the name of the application and I want it to
I currently have a table(/grid) of data that I can page, filter and sort.
Ok, I have a set of checkboxes for selecting criteria. For argument's sake, we'll
I am currently using Django forms with the Google App Engine and I have
I am currently trying to use NAnt and CruiseControl.NET to manage various aspects of
I'm currently creating a WinForm in VB.NET bound to an access database. Basically what
I am currently working on a web application where I have encountered a little
Currently I have a service that uses a UserNamePasswordValidator to authenticate the client user.
Currently I have three tables. GrandParent( tel int, G_Counter int, GField varchar(10)); Parent( tel
Currently my AJAX is working like this: index.php <a href='one.php' class='ajax'>One</a> <div id=workspace>workspace</div> one.php

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.