I have two tables:
Items:
| Item|
A
B
C
userItems:
| UID | Item
1 A
1 C
This loop shows the data from table Items:
$data = mysql_query("SELECT * FROM `Items`ORDER by `Icons` ASC");
while($row = mysql_fetch_array( $data ))
{
echo $row['Item'];
echo "Unlock";
}
Basically I need to display Unlocked instead of Unlock if the user with UID = $uid has the item.
This query gets the user items:
$data = mysql_query("SELECT * FROM `userItems` WHERE `UID` = '$uid'");
I believe the solution is an left join, but I don’t know how to do it. How can I make it work?
Then just use logic in your PHP to display Unlocked when user $row[“items.UID”] equals $uid