Help with... Get options from database (advanced)

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 19, 2011   (RSS)

By zip222 - April 19, 2011 - edited: April 19, 2011

I have a News table that is going to be managed by multiple users. Each user will be set as an Author for this table that so that they only have access to their records. But there will also be some higher level users that will access to all of the records. When a News record is created, the user needs to specify a "section" for the record by selecting it from a drop down menu. Simple enough. But...

For the Author users, I only want them to have the ability to see/select their particular section. But for the higher level users, they need to be able see/select from the entire list of sections.

In the Users accounts, I have a list field (user_type) to indicate what the type of user account. I also have a list field (related_section) to indicate the related section, but this is only used for the Author users.

I have tried using the Get options from database (advanced) to do what I need it do, but I am just getting a syntax error message. Here is the code I have currently:

if ($CURRENT_USER['user_type']!="section") {
$where="";
}
else {
$where="WHERE num='".$CURRENT_USER['related_section']."'";
}

SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>sections`
`<?php echo $where ?>`
ORDER BY title ASC


help?

Re: [zip222] Help with... Get options from database (advanced)

By robin - April 19, 2011

Hey,

I've fixed up your syntax a bit, hopefully that should work for you now.

Robin

<?php
if ($CURRENT_USER['user_type']!="section") {
$where="";
}
else {
$where="WHERE num='".$CURRENT_USER['related_section']."'";
}
?>
SELECT num, title
FROM <?php echo $TABLE_PREFIX ?>sections
<?php echo $where ?>
ORDER BY title ASC

Robin
Programmer
interactivetools.com