Jump to content

[SOLVED] Selecting A Different File Each Day ???


NoviceJ

Recommended Posts

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

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;
}

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 :)

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?

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  ;)

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 ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.