I write the php
$query = "SELECT privilege , no, userName FROM $tableName WHERE userName =
'$inputAccount' and password = '$inputPassword'";
$result = $mysqli->query($query);
if($result){
while ($row = $result->fetch_assoc()) {
printf ("%s %s %s\n", $row["privilege"], $row["no"], $row["userName"]);
}
}
the result is user 2 test
session_start();
$_SESSION["privilege"]=$row["privilege"];
$_SESSION["no"]=$row["no"];
$_SESSION["userName"]=$row["userName"]
echo $_SESSION["privilege"] ;
echo $_SESSION["no"];
echo $_SESSION["userName"];
but the result comes to none things and I have fix it for a long time and cannot find why?
Thx in advance.
Use the below code, the problem was that you are not storing your sql output in variables and accessing the result outside of while loop.