Click to See Complete Forum and Search --> : Two destinations with dirdisplay


kudzugazette
08-03-2008, 12:09 AM
Is there are way to send the links from two dirdisplays to two different pages?

I want the dirdisplay(resources/students) to link to resources/studentsshow.php?page={$file} and I want the dirdisplay(resources/facandstaff) to link to resources/facandstaffshow.php?page={$file}

Also, still trying to figure out how to display the results in reverse alphabetical order.

Thanks so much.

<?php


// CHECK THAT FUNCTION IS NOT ALREADY DECLEARED
if(!function_exists("DirDisply")){
// START FUNCTION
function DirDisply($path){
// START OUTPUT
$data = "";
// OPEN DIRECTORY
$TrackDir=opendir($path);
// CREATE AN ARRAY OF FILES NOT TO SHOW
$badFiles = array(".","..");
// LOOP THROUGH DIRECTORY
while ($file = readdir($TrackDir)) {
// CHECK FILE NAME AGAIN BAD FILES.
if(!in_array($file, $badFiles)){
// DEFINE FILE AND LINK
$data .= "<li><a href='resources/studentsshow.php?page={$file}'>{$file}</a></li>\n";
}
}
// CLOSE DIRECTORY
closedir($TrackDir);
// RETURN DATA
return $data;
}
}

?>
<div id="r_students">
<h2>Resources for students</h2>
<!--
<?php
$results = array(DirDisply("resources/students/"));
rsort($results);
foreach ($results as $key => $val) {
echo $val . "<br>";
}
?>
-->

<?php
$input = array(DirDisply("resources/facandstaff/"));
$result = array_reverse($input);
echo $result;
?>


</div>
<div id="r_staff">
<h2>Resources for Faculty and Staff</h2>
<?php $results = array(DirDisply("resources/facandstaff/"));
rsort($results);
foreach ($results as $key => $val) {
echo ?>
</div>

scragar
08-03-2008, 12:29 AM
erm...

<?php


// CHECK THAT FUNCTION IS NOT ALREADY DECLEARED
if(!function_exists("DirDisply")){
// START FUNCTION
function DirDisply($path){
// START OUTPUT
$data = new Array();
// OPEN DIRECTORY
$TrackDir=opendir($path);
// CREATE AN ARRAY OF FILES NOT TO SHOW
$badFiles = array(".","..");
// LOOP THROUGH DIRECTORY
while ($file = readdir($TrackDir)) {
// CHECK FILE NAME AGAIN BAD FILES.
if(!in_array($file, $badFiles)){

$data[] = "<li><a href='resources/studentsshow.php?page={$file}'>{$file}</a></li>\n";
}
}
// CLOSE DIRECTORY
closedir($TrackDir);
// RETURN DATA
return $data;
}
}

?>
<div id="r_students">
<h2>Resources for students</h2>
<!--
<?php
$results = DirDisply("resources/students/");
rsort($results);
foreach ($results as $val) {
echo $val . "<br>";
}
?>
-->

<?php
$input = DirDisply("resources/facandstaff/");
$result = array_reverse($input);
echo implode("\n", $result);// implode joins the array together
?>


</div>
<div id="r_staff">
<h2>Resources for Faculty and Staff</h2>
<?php $results = DirDisply("resources/facandstaff/");
rsort($results);
foreach ($results as $val) {
echo $val;
}; ?>
</div>

kudzugazette
08-03-2008, 03:05 AM
Unfortunately, still no luck.

Warning: array_reverse() [function.array-reverse]: The argument should be an array in /Library/WebServer/Documents/it/Resources/inc/facandstaff.inc on line 25

Warning: implode() [function.implode]: Invalid arguments passed in /Library/WebServer/Documents/it/Resources/inc/facandstaff.inc on line 26