Hey,
so I want to get data from column by this:
But instead, it shows column name, 'Role'. My code:
What am I doing wrong? What should I do?
Thanks
so I want to get data from column by this:
PHP:
Stats::userData($_SESSION['username'],'role');
PHP:
public static function userData($user,$column = "*")
{
global $conn;
$stmt = $conn->prepare("SELECT :c FROM users WHERE username = :u ");
$stmt->bindParam(":c", $column);
$stmt->bindParam(':u',$user);
$stmt->execute();
$stmt = $stmt->fetchAll();
foreach($stmt as $data)
{
return $data[$column];
}
}
Thanks