How to select from mysqli if value from other table equals specific value?

I really don’t know where to start. So at this moment I have 2 working mysqli statements, but I don’t know how to combine them.

So, I have two tables.

[php]$sql_ONE = mysqli_query($mysqli, "SELECT * FROM todo WHERE status=‘open’ ORDER BY date ASC LIMIT " . $offset . “,” . $items_per_page);
$sql_TWO = mysqli_query($mysqli, “SELECT * FROM permission WHERE memberID=$memberID AND allowed=‘yes’”);[/php]

I use $offset and $items_per_page for pagination.

But here it comes: there’s a second table that contains a list of members, their memberID and a value (yes/no) wether they may see the row from the first statement or not. So in the first mysqli-statement, all rows are selected where status=open. Before this row’s printed on the screen, PHP needs to check if the member who is on the page is allowed to see it. So it should only be shown if allowed=yes.

I don’t want them to be in one table, because then I need a row for every single member.

How can I combine those two tables and show them on my screen, still with pagination showing the right amount of rows?

You are using a relational database. Tables should relate, if you are going to combine them. It sounds more like a roles issue though.

What rule dictates whom can view what?

Sponsor our Newsletter | Privacy Policy | Terms of Service