needs some help please
Im going nuts here. Here is the basic flow of data:
admin logs into backend. fills out a form. This form has a file upload and 4 check boxes. each checkbox is equal to a user level. This allows me to display the file based on user level. Some files may be seen by more than one user level.
my table is as:
table name: policies
id
file_name
1
2
3
4
each number represents a user level
when a file is uploaded and tagged as 3 for example, the data in the "3" field is either 1 or 0.
Now, what I want to do is to display all file_names in 3, that are 1.
Makes sense?
To make matters more complicated, I think I need to define it by '$_SESSION[user_level]'.
I have no idea who to do this. I have tried a ton of things. The closest I have come to is:
$SQL = "SELECT * FROM policies ";
if($_SESSION['user_level']== 1)
{
$SQL = $SQL . "WHERE 1='1'";
}
if($_SESSION['user_level']== 2)
{
$SQL = $SQL . "WHERE 2='1'";
}
if($_SESSION['user_level']== 3)
{
$SQL = $SQL . "WHERE 3='1'";
}
if($_SESSION['user_level']== 4)
{
$SQL = $SQL . "WHERE 4='1'";
}
echo $SQL;
But I still only get one file back, and its usually the first record in the table, doesnt matter if its 1 or 0
This is way out of my league now.. is there an easy way to just : select all "1's" from my table, based on you is logged in?