Hello:
I am using Uniserver 3.1 from sourceforge for my apache,php, and mysql applications. I am also using drupal for the CMS.
I checked at evilwalrus but did not find what I was looking for.
I want to find a php script that allows me to collapse a static directory structure of web links....
For example...
The primary categories would be
Daily
Weekly
Monthly
Under each of those would be several other link references.
Daily
web_link_1
.
.
.
web_link_40
Weekly
web_link_41
.
.
.
web_link_80
Monthly
web_link_81
.
.
.
web_link_120
I need to be able to collapse these subcategories since there are so many.
Could somone please point me to a specific example? Again ... I am not a programmer..... but I need to fing this solution.
Thanks and I hope to learn along the way.
Chris
Simple link structure (I hope) question from a nonprogrammer
Moderator: General Moderators
Just quickly whipping something up, feel free to comment on this if it doesn't make sense or if I'm doing it wrong/inefficient.
Code: Select all
<?PHP
//if no links have been clicked, output top level
$top_level_links = array("Daily","Weekly","Monthly");
if(count($_GET) == 0)
{
//loop through each $top_level_links and put each
// element in $time_period in it's respective loop
foreach($top_level_links as $time_period)
{
echo <<<LINK
<a href = "$_SERVER[PHP_SELF]?period=$time_period">$time_period</a><br />
LINK;
}
}
//if GET is populated, $_GET[period] is a sub-directory we want to view
if(isset($_GET['period']))
{
//Note: this assumes your directories are named the same as the elements in $top_level_links
$dir = "$_GET[period]";//this assumes the directory is in the same directory as the page
$links = scandir($dir);//get items in directory
//loop through $links and put each item in $links
// in $link in it's respective oop
foreach($links as $link)
{
//don't show first two elements
if($link != "." && $link != "..")
{
echo <<<LINK
<a href = "$link">$link</a><br />
LINK;
}
}
}
?>Real programmers don't comment their code. If it was hard to write, it should be hard to understand.