Fetch data from database into checkbox and get the selected values PHP : <p>I am newbie in both PHP and Mysql. I have a table in Mysql named  "has" which i store the physical alignments of customers . There are two attributes CustomerID and PyhsicalAilmentName . In sign up screen i want user to select them in a checkbox. I am able to fetch the phsical alignments from database into checkbox with this form code. </p>

<pre><code>   &lt;form action="includes/signup.inc.php"  style="border:1px solid #ccc;width: 50%;margin: 0 auto" method="post" &gt;
            &lt;div class="container" &gt;
            &lt;h1&gt;Sign up&lt;/h1&gt;
            &lt;p&gt;Please fill in this form to create an account.(Your username should start with "C_")&lt;/p&gt;

                &lt;hr&gt;
            &lt;input type="text" name="username" placeholder="Name"&gt;
            &lt;input type="text" name="user_last_name" placeholder="Last Name"&gt;
            &lt;input type="text" name="uid" placeholder="Username"&gt;
            &lt;input type="password" name="pwd" placeholder="Password"&gt;
            &lt;input type="password" name="pwd-repeat" placeholder="Repeat Password"&gt;
            &lt;input type="text" name="user_weight" placeholder="Weight(in terms of kilogram)"&gt;
            &lt;input type="text" name="user_length" placeholder="Length(in terms of cm)"&gt;
            &lt;input type="text" name="user_age" placeholder="Age"&gt;

                &lt;p&gt; Phsical Alignments&lt;/p&gt;
                &lt;?php
                    $sql = "select Name from physical_ailment";
                    $result = mysqli_query($conn,$sql);
                    $i = 0;

                    while($db_row = mysqli_fetch_array($result)){
                        ?&gt;
                        &lt;input type="checkbox" name="check_list[]"&gt; &lt;?php
                            echo $db_row["Name"]; ?&gt; &lt;br&gt;
                        &lt;?php
                        $i++; }
                        ?&gt;


            &lt;select name="selected_mem_type" &gt;

                &lt;?php
                    $sql = "select Name from membership_type";
                    $result = mysqli_query($conn,$sql);
                    $i = 0;

                    while($DB_ROW = mysqli_fetch_array($result)){
                        ?&gt;
                        &lt;option&gt;
                            &lt;?php echo $DB_ROW['Name']; ?&gt;
                        &lt;/option&gt;
                        &lt;?php
                            $i++;} ?&gt;
            &lt;/select&gt;
            &lt;input type ="text" name="user_card_no" placeholder="Credit Card No"&gt;
            &lt;input type="date" name="user_card_expire_date" placeholder="Expire Date of Card"&gt;
            &lt;button type="submit" class="signupbtn" name="signup-submit"&gt; Signup &lt;/button&gt;
                &lt;button type="submit" class="signupbtn" name="home-submit"&gt; Home &lt;/button&gt;
            &lt;/div&gt;
        &lt;/form&gt;
</code></pre>

<p>Problem is when i intended to get the selected ones with <code>$_POST['check_list']</code>via foreach loop it prints <strong>"on"</strong> according to number of selected checkboxes. If user selects 3 checkboxes  in <code>$_POST['check_list']</code> there are 3 elements which is <strong>"on"</strong> . When I select 2 things lets say , and print the <code>$_POST['check_list']</code> with <code>print_r</code> it outputs <code>Array ( [0] =&gt; on [1] =&gt; on [2] =&gt; on )</code>
I search a lot but couldn't manage to find solution. Appreciate any help thank you for interest.</p>
