page_id or category_id

Hi, I am learning how to lock pages on a cms. - Some pages are within a category, and of course their are the index pages for the category.

At the moment I can call the database to change the “locked” cell to turn off the page, but I can’t figure out how to turn off the category_id index page.

Here is the line I am using:

$locked = $db->query("SELECT * FROM " . $config['db']['prefix'] . "pages WHERE page_id = $page_id AND locked = 1");

I am assuming where the page_id = $page_id is I need to add after category_id = $category_id but I am unsure on how to do this.

Any suggestions would be great.

Cheers,

Paul

does your category table have a locked field too? If so, on your page that generates the index

$locked = $db->query("SELECT category_id, locked FROM "
.$config['db']['prefix']."category 
WHERE category_id = $category_id AND locked = 1");
if($db->num_rows == 1){ 
 echo "sorry bub this category is locked";
}else {
  // show page
}