goofy78270 Posted March 4, 2011 Share Posted March 4, 2011 I have a website that I did for my uncle and now, the requirements are going beyond my html knowledge and into the realm of server scripting. My issue is that I need to loop through all the images in a given folder and subfolders and preload them into the html so that the user can view them within a slide show. There are currently 6 subfolders with over 20 pics in each and there are more pics to come and different folders to add. I have a media page with the first picture within each category (subfolder) displayed as an eye catcher to the category. once the user clicks on the image, the slide show will start in a popup. The problem is that with js, I have to list out every image since it cannot look through a directory listing. I would like to simply call a server side script that will create an array of the images and preload them so that when the slide show is ran, the appropriate images will show. I am found numerous scripts for preloading images, written in php, but I am unsure how to implement them and keep a html extension for my pages. As the site is written entirely in html and javascript, I would like to keep the html extentions if possible. As this is my first site, I am sure that server side scripting will become a bigger role, but baby steps are what I need right now. In addition, if anyone has a good site for learning the server scripting world, I would greatly appreciate the reference. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/ Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 You can't run php from a .html file. You need to change the extensions for the server to know that it has to run scriprs on the page. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182972 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 If I change all my extentions to .php but don't put php code in the pages, will that cause an issue? Could I load the php page within an iframe? Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182977 Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 while html pages can not run php, php pages can handle html quite naturaly. using an Iframe is an option if it's what you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182978 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 If you name all your pages with a php extension, the parser will go through that script. If it finds no PHP code, it will just return the file to the browser. In retrospect, it will slow the site down slightly, as it will take time for the parser to look at the file. I have a script that grabs all images from a directory, but it is made for something a little different. If you post your javascript code, I could put it in there for you. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182983 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 You want the js for the slide show or the html for the page? Can I pm it to you? Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182986 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 Sure, JS for the slideshow. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182988 Share on other sites More sharing options...
flolam Posted March 4, 2011 Share Posted March 4, 2011 Adding this in your .htaccess would result in all *.html files being executed as php, but I'm not sure if there are any disadvantages: AddHandler x-httpd-php5 .html AddType application/x-httpd-php5 .html Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182989 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 Adding this in your .htaccess would result in all *.html files being executed as php, but I'm not sure if there are any disadvantages: AddHandler x-httpd-php5 .html AddType application/x-httpd-php5 .html Do you happen to know if godaddy is setup this way? Is there a simple test I can do to find out? Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1182992 Share on other sites More sharing options...
jcbones Posted March 4, 2011 Share Posted March 4, 2011 Adding this in your .htaccess would result in all *.html files being executed as php, but I'm not sure if there are any disadvantages: AddHandler x-httpd-php5 .html AddType application/x-httpd-php5 .html Do you happen to know if godaddy is setup this way? Is there a simple test I can do to find out? Sure, make sure that code is in your .htaccess file. test.html <?php echo 'If this doesn\'t have the word echo in front of it, PHP is parsed!'; ?> Edit: I MUST ESCAPE!!! Save the above box to a file, and call it with your browser. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183001 Share on other sites More sharing options...
gizmola Posted March 4, 2011 Share Posted March 4, 2011 Yes godaddy supports that, as well as mod rewrite rules which you could use for your existing pages. A common strategy for dynamic websites is to make dynamically generated pages "appear" to be static html files using mod_rewrite. It looks in this case like just remapping .html to be parsed as php is simpler but for completeness sake, I thought I'd mention the alternative. For example, it's not an infrequent occurence that people completely rewrite a site and restructure it, however, they have a lot of google links to what would be obsolete urls, which they don't want to lose. So they put in mod rewrite rules for these links that redirect to the new url where the content has been moved to. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183009 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 Save the above box to a file, and call it with your browser. Thanks for the assistance, but apparently godaddy does not offer access to the .htacess file for the site. and they do not parse html files as php. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183016 Share on other sites More sharing options...
Pikachu2000 Posted March 4, 2011 Share Posted March 4, 2011 I've used them and I've never had a problem using a .htaccess file. What makes you think you can't access yours? Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183023 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 I've used them and I've never had a problem using a .htaccess file. What makes you think you can't access yours? when I browse through the ftp or file manager option, I have no such file. I tried looking through the various setting pages, and nothing referenced .htaccess. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183030 Share on other sites More sharing options...
Pikachu2000 Posted March 4, 2011 Share Posted March 4, 2011 You can create one and upload it; it doesn't have to already exist in the directory. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183036 Share on other sites More sharing options...
gizmola Posted March 4, 2011 Share Posted March 4, 2011 My goodness we are a helpful bunch Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183042 Share on other sites More sharing options...
goofy78270 Posted March 4, 2011 Author Share Posted March 4, 2011 So I added a file .htaccess to the root of the site with the aforementioned information and created a test.html with the information listed and no luck. Come to find out, I am using a Windows server and not an Linux so an .htaccess file will not work. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183056 Share on other sites More sharing options...
Pikachu2000 Posted March 4, 2011 Share Posted March 4, 2011 Yuck. Get them to move you to a Linux box if you can. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183060 Share on other sites More sharing options...
McBryver Posted March 5, 2011 Share Posted March 5, 2011 Tried to use mysql_fetch_row and it gave me a similar error. Quote Link to comment https://forums.phpfreaks.com/topic/229608-new-to-php-how-to-implement-php-and-keep-html-extension/#findComment-1183125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.