Completely new to PHP here,
so on my website I'd like a specific image to appear according to whether or not the user in my DB has a row called 'premium', with a value of 1. I've tried figuring it out on my own but I'm stuck. I watched a video of someone doing something similar so this is what I have currently, but I'm aware it's totally incorrect.
//init.php file
<?php
if (session_status() == PHP_SESSION_NONE) {//php >5.4
session_start();
}
$_SESSION['user_id'] = 1;
$db = new PDO('mysql:host=127.0.0.1;dbname=loginsystem', 'root', '');
$userQuery = $db->prepare("
SELECT idUsers, uidUsers, emailUsers, pwdUsers, premium
FROM users
WHERE idUsers =:user_id
");
$userQuery->execute(['user_id' => $_SESSION['user_id']]);
$user = $userQuery->fetchObject();
//webpage in which the image will appear
<?php
require_once '../includes/init.php';
?>
<?php if($user-> premium): ?>
<img src="../../img/premium.png" alt="Swiftify+"></a>
<?php else: ?>
<img src="../../img/swiftify.png" alt="Swiftify+"></a>
<?php endif; ?>