Php

PHP beginners tutorial 46 – multiple checkboxes



In this tutorial I show you a better way to retrieve data from a check box that allows for multiple check boxes to be ticked.

.
Follow me on Facebook:
www.facebook.com/quentin.watt

Follow me on Twitter:
www.twitter.com/QuentinWatt

Don’t forget to subscribe:
www.youtube.com/QuentinWatt

Donate on PayPal:

xclick&hosted_button_id=DM496T7CTUYAS Donate on PayPal:

Similar Posts

22 thoughts on “PHP beginners tutorial 46 – multiple checkboxes
  1. <table>
    <? php
    while($row = mysqli_fetch_array($result)){
    ?>
    <tr>
    <td>
    <input type="checkbox" name="chk[] " value="<?php $row["email"]"; >
    </td>

    </tr>
    <?
    } ?>
    </table>

    when i call via $_POST in php chk[] array shows its length as 0.
    what should i do.

  2. <table>
    <? php
    while($row = mysqli_fetch_array($result)){
    ?>
    <tr>
    <td>
    <input type="checkbox" name="chk[] " value="<?php $row["email"]"; >
    </td>

    </tr>
    <?
    } ?>
    </table>

    when i call via $_POST in php chk[] array shows its length as 0.
    what should i do.

  3. Hi Quentin,
    I tried the above program as u explained, but dunno why its throwin error,
    Can you please have a look into my code:

    <?php

    $food=$_POST['food'];
    echo "you selected : <br>"
    foreach($food as $k=>$v)
    {
    echo "$v<br>";
    }
    ?>

  4. i have this fucking error….Notice: Undefined index: product-> is the array which i need to use please help me i am disappointed from php cause of this error :/

  5. Seriously, everyone just shows you how to echo back these values. When the hell are you actually going to use php to echo? Show us how to actually process and package this information for server upload or email formatting.

  6. Thank you Quentin,
             my foreach() loop doesnt work!!! I tried both ways but still no luck.

            echo 'You selected: <br/>';
            //$food = $_POST['food'];
                
            foreach($_POST['food'] as $key => $value){
                echo $value.'<br/>';
            }
    I get this error:
    > Warning: Invalid argument supplied for foreach() in /Applications/XAMPP/xamppfiles/htdocs/tutorial/handler46.php on line 22

Leave a Reply

Your email address will not be published. Required fields are marked *