0

Hi all, am trying to use bootstrap switch in my form. Am at a lost as to how to get the value of

name="onoffswitch"

from that field and insert it into mysql db, here is my code...

div class="onoffswitch">
    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
    <label class="onoffswitch-label" for="myonoffswitch">
        <div class="onoffswitch-inner"></div>
        <div class="onoffswitch-switch"></div>
    </label>
</div>
2
Contributors
6
Replies
27
Views
3 Years
Discussion Span
Last Post by dannybarh
0

Thanks for your prompt reply...
but how do i get the values into this query :

$query ="INSERT INTO sre_log_remind VALUES('','$tag','$s_veration')";

mysql_query($query);

so that i can insert the values 'ON' or 'OFF' in to the db?

1

You should save the values as a tinyint(1) - 0 or 1.

if(isset($_POST['onoffswitch']))
{
    $switch = 1;
}else{
    $switch = 0;
}

Or a one-liner...

$switch = (isset($_POST['onoffswitch'])) ? 1 : 0;

Then...

$query ="INSERT INTO sre_log_remind VALUES(NULL,'$tag',$switch)";    
Votes + Comments
perfect solution
0

thanks Diafol, i will am giving it a try. Your contributions are always rich and deep. How long have you been programming...?

0

Hmm, difficult to say - I've been 'playing' at programming for about 20 years. Only started to make it a serious hobby about 5 years ago. I'm not a professional programmer - that aspiration - unfortunately - is beyond my abilities - but I do enjoy playing.

0

LOL, thanks for your help man, it worked perfectly.Am working hard, so i can be of help to others, Greate Work Man...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.