lundi 3 août 2015

If statement doesn't recognize zero values

$_POST value is boolean (1 or 0). When it's set as zero, PHP thinks that it's not set. Same happens using $_GET. I haven't any idea of solving this...

if (isset($_POST["value"])) {
        $value = $_POST["value"];
    } else {
        $value = null;
    }

if ($value) { 
    $sql .= " AND `value` = :value";
}

Aucun commentaire:

Enregistrer un commentaire