I am attempting to us glob to display contents of a users folder using a session variable.
Example: I have a session variable called department
$row_fullname['department'];
In department I have the name of the department the user belongs to such as: office, plant, maintenance, and groundskeeping
I created a folder called docs inside of docs there are 4 subfolders called office, plant, maintenance, and groundskeeping
I found this code which will display the contents of the folder:
<?php
$files = glob( './docs/office/*.*' );
foreach ( $files as $file )
{
echo
'<a href="./docs/office/' . basename( $file ) . '"target="_blank">'
. basename( $file ) . '</a><br />';
}
?>
The above code works fine, but I would like it to only display the contents of a departments folder only if the user is part on that department.
Here is an example that I know is completely wrong but it may help explain what I am trying to do.
<?php
]<?php
$files = glob( './docs/echo $row_fullname['department'];/*.*' );
foreach ( $files as $file )
{
echo
'<a href="./docs/echo $row_fullname['department'];/' . basename( $file ) . '"target="_blank">'
. basename( $file ) . '</a><br />';
}
?>
Thanks for your time