jeudi 13 août 2015

insert multiple checkboxes in one column of a table using implode function

i have this checkboxes in my code

<fieldset><legend>What search engine do you prefer?</legend><br><br><br>
        <!-- container ko start -->
        <div id="container2">

            <table>
                <tr>
                    <td width="30%">
                        <label><img src="images/google.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]" value="google">
                    </td>
                    <td width="30%">
                        <label><img src="images/yahoo.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]"  value="yahoo">
                    </td>
                    <td width="30%">
                        <label><img src="images/bing.png" height="40px" width="120px"></label>
                        <input type="checkbox" name="engine1[]" value="bing">
                    </td>
                </tr>

            </table>

        </div>
    </fieldset>


    <br><br><br><br><br>
    <fieldset><legend>Put check on the icons that you are familiar with.</legend><br><br><br>

        <div id="container2">

            <table>

                <tr>
                    <td>
                        <label><img src="images/fb.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="fb">
                    </td>
                    <td>
                        <label><img src="images/twit.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="twitter">
                    </td>
                    <td>
                        <label><img src="images/googplus.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="googleplus">
                    </td>
                </tr>


                <tr>
                    <td>
                        <label><img src="images/link.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="linkedin">
                    </td>
                    <td>
                        <label><img src="images/pin.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="pinterest">
                    </td>
                    <td>
                        <label><img src="images/del.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="delicious">
                    </td>
                </tr>


                <tr>
                    <td>
                        <label><img src="images/stumb.png" height="40px" width="55px"></label>
                        <input type="checkbox" name="engine2[]" value="stumbleupon">
                    </td>
                    <td>
                        <label><img src="images/diig.png" height="40px" width="40px"></label>
                        <input type="checkbox" name="engine2[]" value="diigo">
                    </td>
                </tr>


            </table>


        </div>
        <!-- container ko end -->
    </fieldset>

two sets which the names are engine1 and engine2. i wanted to insert them in my database using implode with this code..

$_POST['engine1'] = array();
    $_POST['engine2'] = array();

    $engine1 = implode(',', $_POST['engine1']);
    $engine2 = implode(',', $_POST['engine2']);

but everytime i check my database table, the columns are empty. what part do you think am i doing it wrong?? please help!




Aucun commentaire:

Enregistrer un commentaire