I have the following select in my form, which I need to save in my database:
<select name="openhours" class="form-control selectpicker" >
<option value=" " >Open Sundays</option>
<option>Yes</option>
<option>No</option>
</select>
I made a boolean column in MySQL database. But first of all I cannot figure out if a boolean column still is a name for tinyint
?
I have made the following insert function which is working perfectly fine. But how can I bind a boolean in my insert function?
<?php
if(isset($_POST["headline"], $_POST["description"])) {
$head = trim($_POST["headline"]);
$desc = trim($_POST["description"]);
$stmt = $mysqli->prepare("INSERT INTO stores (headline, description) VALUES (?, ?)");
// bind variable
$stmt->bind_param('ss', $head, $desc); // bind
// execute prepared statement
if ($stmt->execute()) {
$success = true;
}
// close statement
$stmt->close();
// close connection
$mysqli->close();
if($success) {
echo "Insert Succesfull";
} else {
echo "Failed: " . $stmt->error;
}
}
?>