mysql - sql/php query to set the value of a variable -


i have table called "users" has columns 'username', 'password' , 'permission'. in permission column either 'browse' or 'edit'. have user logged site, want select select permission using username (which have stored in session variable). want set variable equal either 'browse' or 'edit' based on permission, use in further logic.

assuming have connected , selected appropriate database pretty sure php code , query should go like:

 $u = $_session['username'] ;  $sql = "select permission users username = '$u' " ;  $result = mysqli_query($sql); 

but im unsure how set variable equal 'browse' or 'edit' accordingly.

any ideas?

say have connection $con, using session have start session.

$u = $_session['username'] ; $sql = "select `permission` `users` username='$u'"; $result = mysqli_query($con, $sql); $rows = mysqli_fetch_object($result);  //now time set permission variable echo $permission = $rows->permission; mysqli_close($con); 

you can set $permission $_session.

$_session['permission'] = $permission; 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -