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?
Itemstable at all? You haveItemcolumn inuserItemsas well.userItemson registration and add another column but it's easier to have a different table in case I want to add new items in the future.Itemstable than a single column,Iconsfor example