I'm trying to create a checkbox where the user will select their 'diseases affected: heartdisease, cancer, diabetes' and hit the submit button and will be saved into the database respective columns as as either '1' for yes or '0' for no. I've tried googling for the answer but I can't seem to find any. Any example would be appreciated thanks.


Here are the samples of ones and zeros take your pick...

    $x = false;
    $y = true;
    $z = NULL;
    $a = 0;
    $b = 1;

    ## as dumps
    echo "<br/>";
    echo "<br/>";
    echo "<br/>";

    ## as boolean to integer to reflect 0 as false and NULL,  and 1 as true. NULL and NOT NULL can also be set on your database table.
    echo "x = ".(int)$x."<br/>";
    echo "y = ".(int)$y."<br/>";
    echo "z = ".(int)$z."<br/>";

    ## these two are integers.
    echo "a = ".$a."<br/>";
    echo "b = ".$b."<br/>";

    ## as boolean without the integer intervention. here x and z does not have  VISIBLE output values.
    echo "x = ".$x."<br/>";
    echo "y = ".$y."<br/>";
    echo "z = ".$z."<br/>";

    ## however, condition below confirms that x , z, and $a are  zeros. Please consider this. This is the situation when generous parenthesis matters, or else evaluation will not return plausible response.?????????
    if(($z && $x && $a ) == 0){
       echo "They are false, NULL, and ".$a;

next the form implementation which is pretty easy... I think..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.