[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

How can I use PHP to automatically create an archive page with drop down menu linking to HTML files from a folder?

Asked by rapidpictures in Web Authoring, PHP and Databases, Hypertext Markup Language (HTML)

Tags: PHP automatically archive auto menu

Hi,

I have already had assitance creating php code to display pages based on the date, using convetion 'day_month_year.html', e.g. 22_09_2009.html
(thanks Silhouette!)

see http://www.experts-exchange.com/Web_Development/Authoring/Q_24746809.html

NB fitness instructor wishes to prepare daily / weekly fitness programmes in advance, so that a folder with a years worth of content can be pre uploaded, thus reducing admin.

I would like to take this further and have an archive page with a drop down menu which automatically populates with any existing files up to and including today's date, specifically any files whose name is later than today's date would not be displayed.
folder full of files
01_09_2009.html
11_09_2009.html
18_09_2009.html
29_09_2009.html
10_10_2009.html
22_10_2009.html
etc

So, given that today is the 22nd September 2009  all files up to including 18_09_2009.html will populate a dropdown menu.

This page is being intergrated in to a private members area, using phpAMA. php AMA has a main page with a dropdown menu for any pages uploaded to a specific folder.

I would like to emulate this on the archive page.

So I'm looking for php to search a folder for files named up to and including today's date, then present them as a dropdown menu on the archive page. The drop down navigation needs to be maintained when a page is selected.

Many thanks,

Owen
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
// code to auto load files based on name and date
<?
$folder = "weekly_content/";
$maxDays = 30;
$currDate = mktime();
$counter = 0;
do {
	$file = $folder .date("d_m_Y",$currDate). ".html";
	$currDate = strtotime("-1 day",$currDate);
}
while(!file_exists($file) && $counter++ < $maxDays);
 
	if($counter > $maxDays) {
	echo "error";
}
else {
	include($file);
}
?>
	
 
// the code used by phpAMA to find files in a folder that I need to modify to find files named up to today's date only. These become available in a dropdown menu (ideally omitting the '.html'). It would be great to have this as navigation added to the top of each page! Thanks.
 
<?php
$handle = opendir('content/');
$i=0;
while($item=readdir($handle))
{
 $the_files[$i]=$item;
 $i++;
}
sort ($the_files, SORT_STRING);
reset ($the_files);
 
while (list ($key, $item) = each ($the_files))
{
 if (((ereg(".html",$item)>0)||(ereg(".html",$item)>0)||(ereg(".php",$item)>0))AND($item!=INITIAL_PAGE)AND($item[0]!="_"))
 {
  $item_array=explode(".",$item);
  echo "<option value=\"$item\">$item_array[0]</option>";
 }
}
closedir($handle);
?>
[+][-]09/22/09 11:15 AM, ID: 25395794Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/22/09 11:29 AM, ID: 25395937Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/22/09 11:40 AM, ID: 25396038Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/22/09 02:32 PM, ID: 25397839Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/22/09 04:23 PM, ID: 25398594Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/23/09 11:38 AM, ID: 25406387Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/23/09 02:51 PM, ID: 25408321Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Web Authoring, PHP and Databases, Hypertext Markup Language (HTML)
Tags: PHP automatically archive auto menu
Sign Up Now!
Solution Provided By: fibo
Participating Experts: 1
Solution Grade: B
 
[+][-]09/23/09 03:13 PM, ID: 25408541Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/23/09 04:31 PM, ID: 25408988Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625