0
votes

I'm stuck with these saving checkboxes to database.

I have created a contactlist crud in YII. Later I have generated checkboxes for each contactlist in "manage contacts".

All I am worried is the method of storing these checked values to database. How can I do that?

2

2 Answers

0
votes

Like this?

in HTML form:

<form action="post.php" method="post">
<input type="checkbox" name="test" value="value"/>

post.php:

if($_POST['test'] == 'value')
{

  //sql code
}
0
votes

Maybe the problem is only when you don't check any of your checkboxes because when is unchecked any value is send to the server, only when is check it will be send to the server, yo can try something like this

<input id="ytform_results_enclosing" type="hidden" name="form_results[enclosing]" value="0">

<input id="form_results_enclosing" type="checkbox" value="1" name="form_results[enclosing]">

what that means is , if your check your checkbox then the value of checkbox sended to the server will be "1", if not will be send a "0", you have to do it that way, otherwise nothing will be send to the server, maybe that is what happening to you.