Trying to display a different pic for the logged in user if it's an admin or a simple user. Here is my function
function isAdminPhotoChange() {
// check if user is admin or user
if (isset($_SESSION['user']) && $_SESSION['user']['user_type'] == 'admin') {
if (file_exists("images/metcircle13.png")) {
$filename = "$metcircle13.png";
echo '<img src="images/<?php echo'. $filename.'?>" style="height: 50px;">';
} else {
if (isset($_SESSION['user']) && $_SESSION['user']['user_type'] == 'user') {
$filename = "user_profile.jpg";
echo '<img src="images/<?php echo'. $filename.'?>" style="height: 50px;">';
}
}
}
}
And here is the call in another php file
<?php
include("functions.php");
$comm = mysqli_query($db, "select name,comment,post_time from comments");
while($row=mysqli_fetch_array($comm)){
$name=$row['name'];
$comment=$row['comment'];
$time=$row['post_time'];
}
?>
<div class="sxolion">
<strong style="margin: 3px; color: #000; text-shadow: 2px 2px 5px #3d5c5c;"><?php isAdminPhotoChange(); ?><br><p style="margin: 4px;"><?=$name?></p></strong><p style="margin: 3px;"><?=$comment?></p><span class="time"><br><p style="margin: 4px;"><?=date("j/m/Y g:i:sa", strtotime($time))?></p></span>
Thank You!