Get 1 query value to a variable
I am running a query and i need to get only 1 value. i currently have,
$sql = "SELECT userId FROM UserAccountInfo WHERE loginName = '$userName'";
$result = $con->query($sql);
$row = $result->fetch_array(MYSQLI_NUM);
$userId = $row[0];
i need a shorter way to get userId to a variable. there a way i don't have
to use the fetch_array thing. i know there is only one thing in the query
so why use an array.
No comments:
Post a Comment