table1: id (autoincrement) username category
table2: id (autoincrement) itemname category
I have 2 queries.
1 query one shows categories that a user (logged in) belongs to:
$sql = "SELECT * FROM table1 WHERE '$login_session' = username";
I can list each record:
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "category: " . $row["category"]. "<br>";
}
That works fine.
My 2nd query is dependent on the 1st query. I need to list all records from table2 where category belongs to in array category in previous query.
$sql2 = "SELECT * FROM table2 WHERE category = I DO NOT KNOW WHAT TO PUT HERE";
How do I write $sql2?