I need to display different verbiage according what the user's status is. I realize the while() variables are out of scope to Online_Status() but I cannot figure out how to share the variables or even define new variables in Online_Status() contianing the same information as while(). I've tried putting Online_Status() in while(), around while(), outside of while() and every other configuration for hours. Not happening. I would appreciate any help!
<?php
require_once('connect.php');
$con = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME) or die('Connection failed: ' . mysqli_connect_error());
$sql = mysqli_query($con, "SELECT UserType, Online, InChat FROM membership WHERE UserType = 2 ORDER BY Online DESC");
while($row = mysqli_fetch_array($sql)){
$UserType = $row['UserType'];
$Online = $row['Online'];
$InChat = $row['InChat'];
echo Online_Status();
}
function Online_Status(){
if ($Online == 0) {
echo "I am not online. Please come back later";
}
else if($Online == 1 && $InChat == 0){
echo "I am Online and I will be in my chatroom shortly.";
}
else if($Online == 1 && $InChat == 1){
echo "I am Online chat with me now!";
}
}
mysqli_close($con);
?>