Difference between left join and inner join table

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 9
Joined: Mon Mar 19, 2018 4:14 am

Thu May 10, 2018 7:18 am

Hey guys...

I am trying to create a piano website where users can learn how to play the piano by watching video tutorials. I would like the users to have accessed to either the primer level for free but have to pay for level 1, level 2 and level 3. I have got a website by following mmtuts on youtube lesson 45 and i have two tables called users and user_access, which contains the levels.

When I tried to run this code...
ut if I do this, then it won't work:

include_once 'includes/dbh.php';

$sql = "SELECT users.user_first, user_access.access_type as accesslevel FROM users
LEFT JOIN user_access ON users.user_access = user_access.id


$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if($resultCheck > 0) {
while($row = mysqli_fetch_assoc($result)) {
if ($row['accesslevel'] != 'primer level') {
header("Location: index.php?signup=accessdenied");
} else {
echo ' Welcome to the content';



I get access denied for both users

php-forum Fan User
php-forum Fan User
Posts: 577
Joined: Fri Apr 01, 2016 2:18 am

Thu May 10, 2018 8:24 am

Your condition is false - just check it with var_dump().

If you want somebody to help: provide a full example with table structure and example records, or nobody knows what data your problem relies on. It's easy to mock up some data with SQLITE in memory tables and PDO.

Post Reply