Basic html page help required?
Hi
I need to be able to pick up the names of all html files from a directory automatically on a daily basis as well the first 2 or 3 lines, and put them on my main page like this:
How do i wash my face without chemicals?
Thats easy just use natural fruits and olives in your bowl.
But remmeber also the water you use is also important, as water dries our skin.
Who do i ask for a facial massage?
Its really not a question of whom you should ask, but rather how you ask them, i personally would ask someone who pays attention to what he or she does.
Is this possible? or do i have to manually do it, as i have 15+ html pages daily that i do for my spa shop on my website?
I am using notepad as my editor.
Kind Regards
Tovia
Public Comments
- you can do it with php if you have access to it <?php //modified example from php.net to fill your need $dirPath = 'path of the directory'; if ($handle = opendir($dirPath )) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo '<a href="http://" . $_SERVER['HTTP_HOST'] . '/' . $dirPath . '/' . $file . '">' . $file . '</a>'; } } closedir($handle); } //to get teh contents just do a fget() function on the file; ?> without using a script the answer would be a no
- It sounds like something using RSS (Really Simple Syndication) would be of use here. It is basically a way to publish certain parts of your website, and it would update itself automatically every specified time frame, in your case every day. For more information check out the link in the sources for my answer! Hope this helps.
- Sounds like you need to start using a CMS, like WordPress http://wordpress.org instead of updating 15 .html files a day. What you're thinking of can be done with WordPress and is a simple PHP script pulling in the title and first X amount of lines/characters/words in the posts and displaying them. I would suggest making your life a heck of a lot easier and using a CMS like WordPress.
- The keyword here is "automatically". This means you want some kind of program that will scan a directory and add the titles to your main page. There are numerous ways of doing this. The most professional is to switch to a database and instead of creating small HTML files, you will just create templates that would show your news. But this requires a database server, a database with tables, and then knowledge of some programming language like PHP. A small step towards that is to have your main page scan the directory for HTML files, create titles from the names of the files, and then write the titles to your page. This means that your main page has to stop being HTML and should start being PHP (or ASP, PERL, JSP or some other scripting language). I'm going to show you an example of a PHP page that does the above: -------------------------------- <HTML> <HEAD><TITLE>My Main Page</TITLE></HEAD> <BODY> News:<BR> <? //Scan the directory for html files if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strpos($file,".html") { $files[]=$file; } } closedir($handle); } //Print links to our news if (count($files)) { //Parse all files foreach ($files as $file){ //Extract the name of the file, without the extension list($name,$ext)=split($file,".html"); //Create an HTML link print("<A href=\"".$file."\">".$name."</A>" //Separate links by a <BR> print("<BR>"); } } ?> </BODY> </HTML> ----------------------------------- Save this entire piece of code into a file named index.php and put it in a directory accessible by your server. You'll need a server that can understand PHP files, otherwise you will only get this text, instead of links to web-pages. You can either install a server yourself (a good choice would be the Apache Server ) and then download and install PHP for your server, or you could use the services of a hosting company and host your files on a remote server, instead of your own computer. To access the server on your computer, use http://localhost/ as the website's link. Hope that helps! Good luck!
Powered by Yahoo! Answers