Ok, so I have been working a Mysql class. I am making a form that will get information about the user logged in. I have a function with in the class that is supposed to do this but I am having a hard time accomplishing this. I am using Prepared Statements. What I want to do is return an array of the data from the database.
Here is the code I have so far:
<?php
require_once('constants.php');
class Mysql {
private $conn;
function __construct(){
$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or
die("There was an issue connecting to the database");
}
function user_info($username){
//query
$query = "SELECT * FROM users WHERE username = ? LIMIT 1";
//prepare query and execute
if($stmt = $this->conn->prepare($query)){
$stmt->bind_param('s', $username);
$stmt->execute();
//WHAT DO I DO HERE
$stmt->close();
return $data;
}
}
}
?>
After the execute you would do something like this: