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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:24:03+00:00 2026-05-14T20:24:03+00:00

Hi, ive been dealing with this for some time now and need your help.

  • 0

alt textHi, ive been dealing with this for some time now and need your help. well I have an array $arrayAmenities which contains a combination of the following data based on what is fetched from the database:

Air Conditioned
Bar
Brunch
Party Room
Tea Room
Terrace
Valet

I would like the application to dynamically check the following set of checkboxes based on the data contained in the array.
With my code only one checkbox is checked based on the first data contained in the array.

Can you please tell what Im missing? Thanks for answering.

code:

//get amenities one by one in order to set the checkboxes
        $arrayAmenities = explode(',', $rest_amenities );

        $i=0;
        while(count($arrayAmenities) > $i)
        {
            var_dump($arrayAmenities[$i]);
            switch($arrayAmenities[$i])
            {
                case 'Air Conditioned':
                    $checkedAir = 'checked=true';
                    break;

                case 'Bar':
                    $checkedBar = 'checked=true';
                    break;

                case 'Brunch':
                    $checkedBru = 'checked=true';
                    break;

                case 'Party Room';
                    $checkedPar = 'checked=true';
                    break;
            }


            $i+=1;
        }

    }

checkboxes

<table cellpadding="0" cellspacing="0" style="font-size:10px">
                        <tr>
                            <td style="border-top:1px solid #CCC;border-right:1px solid #CCC;border-left:1px solid #CCC; padding-left:5px   ">Air Conditioned <input type="checkbox" name="air_cond" <?php print $checkedAir;?> value="Air Conditioned"></td>
                            <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC;">Bar <input type="checkbox" name="bar" value="Bar" <?php print $checkedBar;?>></td>
                            <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; ">Brunch <input type="checkbox" name="brunch" value="Brunch" <?php print $checkedBru;?>></td>                          
                        </tr>

                        <tr>
                            <td style="border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC; border-left:1px solid #CCC; padding-left:5px">Party Room <input <?php print $checkedPar;?> type="checkbox" name="party_room" value="Party Room" ></td>
                            <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Tea Room <input type="checkbox" name="tea_room" value="Tea Room" ></td>
                            <td style="padding-left:10px; border-top:1px solid #CCC;border-right:1px solid #CCC; border-bottom:1px solid #CCC;">Terrace <input type="checkbox" name="terrace" value="Terrace"></td>                         
                        </tr>

                        <tr>
                            <td colspan="3" style="border-bottom:1px solid #CCC; border-left:1px solid #CCC; border-right:1px solid #CCC; padding-left:5px">Valet <input type="checkbox" name="valet" value="Valet" ></td>
                        </tr>
                    </table>
  • 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-14T20:24:03+00:00Added an answer on May 14, 2026 at 8:24 pm

    Thanks you all, thank to your advices I managed to get it done:
    I made the following changes to my code and it work fine:
    First I took off the while and switch and did the following:

    $arrayAmenities = explode(',', $rest_amenities );
            $elt = implode(',', $arrayAmenities);
    

    As for the checkboxes, i just set the following as checked=true:

    <?php strStr($elt, "Air Conditioned")?print"checked=true":print "";?>
    

    I repeated the step above for all the checkboxes and it works perfectly. Thank you all for your suggestion which helped me a lot.

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

Sidebar

Related Questions

Ive been smashing my head with this for a while. I have 2 completely
I've been using TortoiseSVN in a Windows environment for quite some time. It seems
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Ive recently been asked to recommend a .NET framework version to use in a
I've been programming for 10+ years now for the same employer and only source
First off, I'd like to apologize in advance for not knowing this. I've been
When dealing with .vimrc configuration files in Linux and Windows (two systems I've been
I'm working on a project where I need to evaluate some formulas in VB.NET.
I'm sorry if this has been asked before, I tried many combinations of keywords
I've been using PHP & MySQL for ages and am about to start using

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.