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>
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>