NoviceJ Posted September 1, 2008 Share Posted September 1, 2008 Well what im trying to do basicly is say.. i have a different file.. a schedule in this instance but it changes everyday but its the same each week. as im a complete noob at php i did do a little googlin to see if i could find an answer so i could give it a bash myself but i failed anyways what i tried was using switch (date(checkdate())-> switch (date("D")) { // Mondays Schedule case "Mon": include "mondays.html"</P>; break; basicly the same all the way down til sunday as you can see.. or maybe not from laughin so much.. i aint very php orientated. so heres what im trying to acheive.. i either want to load the php file into a iframe on my site.. which will load the data from either html or a flat file.. probably html though.. and it will load a different file each day from mon - sun .. would be greatful for some help or even if someone could come up with a better soloution that would be ace.. Thanks in advance NoviceJ Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/ Share on other sites More sharing options...
The Little Guy Posted September 1, 2008 Share Posted September 1, 2008 Something like this: According to this, the files are in the same directory as the php script switch (date(checkdate())-> switch (date("D")) { case "Mon": include "mondays.html"; break; case "Tue": include "tuesdays.html"; break; case "Wed": include "wednesdays.html"; break; case "Thu": include "thursdays.html"; break; case "Fri": include "fridays.html"; break; case "Sat": include "saturdays.html"; break; case "Sun": include "sundays.html"; break; } Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631397 Share on other sites More sharing options...
Fadion Posted September 1, 2008 Share Posted September 1, 2008 Try this: <?php //will return mon, tue, wen,... $day = strtolower(date('D')); switch($day){ case 'mon': include('monday.html'); break; case 'tue'; include('tuesday.html'); break; } //or use this other method //the date returned will be: monday, tuesday,... $day = strtolower(date('l')); include($day . '.html'); ?> I would suggest the second way. EDIT: The Little Guy beat me to it Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631398 Share on other sites More sharing options...
NoviceJ Posted September 1, 2008 Author Share Posted September 1, 2008 Thanks guys i'll give them a bash.. no doubt i wont get it workin See how usin the include.. if i say use the iframe on my page to grab the php contain that code.. it should show the html page?.. or would i have to do something else to achieve that? Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631408 Share on other sites More sharing options...
NoviceJ Posted September 1, 2008 Author Share Posted September 1, 2008 Its cool GuiltyGears one worked but for some reason The Little Guys Never .. thanks muchos love Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631453 Share on other sites More sharing options...
knowj Posted September 1, 2008 Share Posted September 1, 2008 Noooo iFrames (unless your using it for a similar method to google images) If you want to archive the effects of an iframe use a div with a fixed width/height and apply an overflow. when you have the wonders of php includes dont bastardise your site with iframes Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631458 Share on other sites More sharing options...
NoviceJ Posted September 1, 2008 Author Share Posted September 1, 2008 hehe.. i will probably be using div.. but i was testing within an iframe at the time and yeah i know what you mean iframes do bastardise sites.. the bloomin bastardisers that they are. Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631467 Share on other sites More sharing options...
Fadion Posted September 1, 2008 Share Posted September 1, 2008 Iframes must burn in hell...ok maybe i'm exaggerating a bit Don't know which method you tested, but for a simple code, better use the second approach i suggested. If your html files are named like: mondays, tuesdays, etc, you can just rename them to monday, tuesday, etc, or add an "s" to the concatenated string. I mean: <?php //as suggested in the first post $day = strtolower(date('l')); include($day . '.html'); //or $day = strtolower(date('l')); include($day . 's.html'); //it will include: mondays.html, tuesdays.html, etc ?> Cleaner and simpler code Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-631469 Share on other sites More sharing options...
NoviceJ Posted September 2, 2008 Author Share Posted September 2, 2008 looks like i'll have to use iframes seein how its to much of a pain in the but to call from a div unless its inside a php page but yes thats the code im using works a treat thanks very much Link to comment https://forums.phpfreaks.com/topic/122276-solved-selecting-a-different-file-each-day/#findComment-632154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.