I created a function that is able to print information on screen. However I cannot use this function to store this data in an $variable. I'm also not able to call this into the if comparator (it directly prints it on screen).
Here is an example how i would store the data:
$usertype = getusertype();
or using it in an if statement:
if(getusertype==1){
something}
Here is my function
function getusertype(){
global $con; /* getting the needed data for the query */
$myusername = $_SESSION['myusername']; /* defining the query */
$sql3 = "SELECT usertype FROM person WHERE person_id='$myusername'";
if ($result = mysqli_query($con,$sql3)) {
/* fetch object array */
while ($row = $result->fetch_row()) {
printf ("%s ", $row[0]);
}
/* free result set */
$result->close();
} }
Thank you for looking into it :) (if you do)
Aucun commentaire:
Enregistrer un commentaire