I am using mysqli to query an item database. I am trying to create an array out of the items in the database, but am stuck. Here is what I have so far.
$DB_HOST = 'localhost';
$DB_USER = 'root';
$DB_PASS = '';
$DB_NAME = 'test';
$connection = mysqli_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if ($query = $connection->prepare('SELECT name, due_date, complete FROM items WHERE user_id = ?')) {
$query->bind_param('i', $_SESSION['id']);
$query->execute();
$query->store_result();
//var_dump($query->num_rows);
if ($query->num_rows > 0) {
$query->bind_result($name, $due_date, $complete);
//$query->fetch();
while ($query->fetch()) {
}
}
$query->close();
}
I am completely unsure how to turn this into an array for use in a foreach loop in my list of items.