I'm trying to get a 1
or a 0
from the result, but how do I retrieve it and use it as a simple variable to compare with other variable? I want to use my variable $result_1
and check if it has the value of 1
or 0
.
//
$stmt = $db->prepare("SELECT status FROM todo WHERE id=?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result_1 = $stmt->get_result();
Take a look at the documentation http://php.net/manual/en/mysqli-stmt.get-result.php
In the examples it states that get_result()
returns a result set. Which is basically a container for all the rows that came back. They can be aquired by the following procedure.
$result = $stmt->get_result();
$row = $result->fetch_assoc();
$result_1 = $row['status'];
My example assumes that data came back.