Forum Moderators: coopster

Message Too Old, No Replies

Getting day of the month.

         

Simone100

8:04 pm on Sep 19, 2006 (gmt 0)

10+ Year Member



Hi, I want each entry in my array to appear for each day of the month.

Which would I add to it?

$Date=echo date('D'); or $Date=echo date('D d-M-Y');

or something else? Thanks you very much!

Please don't tell me to look in the manual, thats why I'm here.

rokec

8:10 pm on Sep 19, 2006 (gmt 0)

10+ Year Member



Can you describe your problem better?
$var = echo ("Hi!"); is incorrect, because you can't set the function to variable. Echo() is a function.

Simone100

6:13 pm on Sep 21, 2006 (gmt 0)

10+ Year Member



Sure, I only mentioned echo because someone else said I needed it.

For instance

$content = array (
"htmlpage" => 1,
"htmlpage" => 2,
);

The numbers being the day of the month.

What will call each of the numbers by day of the month using php? Thanks!

I can piece the rest together all I need is how to call it per day.

supermanjnk

6:33 pm on Sep 21, 2006 (gmt 0)

10+ Year Member



I'm not sure if this is what you are looking for, but if it isn't i'm sure you can easily modify it to do what you need.
<?
// builds an array of pages for dates
$content = array();
$content["01"] = "day1.htm";
$content["02"] = "day2.htm";
$content["03"] = "day3.htm";
$content["04"] = "day4.htm";
$content["05"] = "day5.htm";
$content["06"] = "day6.htm";
$content["07"] = "day7.htm";
$content["08"] = "day8.htm";
$content["09"] = "day9.htm";
$content["10"] = "day10.htm";
$content["11"] = "day11.htm";
$content["12"] = "day12.htm";
$content["13"] = "day13.htm";
$content["14"] = "day14.htm";
$content["15"] = "day15.htm";
$content["16"] = "day16.htm";
$content["17"] = "day17.htm";
$content["18"] = "day18.htm";
$content["19"] = "day19.htm";
$content["20"] = "day20.htm";
$content["21"] = "day21.htm";
$content["22"] = "day22.htm";
$content["23"] = "day23.htm";
$content["24"] = "day24.htm";
$content["25"] = "day25.htm";
$content["26"] = "day26.htm";
$content["27"] = "day27.htm";
$content["28"] = "day28.htm";
$content["29"] = "day29.htm";
$content["30"] = "day30.htm";
$content["31"] = "day31.htm";
// end of the array
$date = date('d'); // This is the current date

if (isset($content[$date]) && file_exists($content[$date])) { // checks to make sure the date exists in the array and that the file you are including actually exists
//Your function goes here , in your cause you would want to use include probably
include($content[$date]); //Includ the date file
echo "Including $content[$date]";
} else {
// if the date doesn't exist which should never happen unless you are in a timewarp it will include the default file
include('default.html'); //Include the default file
echo "Including Default File";
}
?>

Simone100

7:09 pm on Sep 21, 2006 (gmt 0)

10+ Year Member



Hey thanks! and for the extra's. I thought that was the right way to call the date, I asked someone elsewhere and they said I needed the ones I asked here instead. I'll try it. ;)

Simone100

7:11 pm on Sep 21, 2006 (gmt 0)

10+ Year Member



Ha, Ha, Ha, I just saw your time warp comment, too funny!

jatar_k

7:15 pm on Sep 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the other thing you could do is this, including the tests from above

$myincludefile = 'day' . date('d') . '.html';
if (file_exists($myincludefile) include $myincludefile;
else include 'defaultpagename.html';

though you would need to have your files properly named with the leading 0's

Simone100

8:00 pm on Sep 21, 2006 (gmt 0)

10+ Year Member



I bet this isn't a tested copy. If it is I am doing something wrong, please let me know.

It wasn't calling the default file but I think thats because its not
calling the .html files either. I took the default out when not working just to test without it. The php wants to work, I am getting no error messages but it is no html page appears.

Do I have to stipulate somewhere what kind of file to call? Or will it put any kind of file in thats included in the array...

Thanks a bunch. :)

supermanjnk

11:27 am on Sep 22, 2006 (gmt 0)

10+ Year Member



Did you make any changes to the code? if so what changes did you make? I'm not sure if you are using mine or jatar_k's but mine is tested, and works, and his should work too.

Simone100

1:16 pm on Sep 22, 2006 (gmt 0)

10+ Year Member



All I did was make an include command on another .php page. I'm using yours super. I have them both in the root, I'll try putting them both in the same directory.

P.S. Do I also put the dafault page in here? or leave as is, I tried both ways.
"Including Default File";

supermanjnk

2:05 pm on Sep 22, 2006 (gmt 0)

10+ Year Member



I have these files

date.php
default.html
day01.htm through day31.htm

These are all in the same directory
which is webroot/dev/days
(http://dev/days/page.php)

Simone100

2:30 pm on Sep 22, 2006 (gmt 0)

10+ Year Member



OOOPs, I think I know what the problem is. I am trying to call actual
url's elsewhere. A new web site url each day. So they won't be in the directory. Any suggestions? Thanks.

Simone100

3:24 pm on Sep 23, 2006 (gmt 0)

10+ Year Member



No that wasn't the problem either. I started this from the basics again and did it completely your way. Thought if I could get it to work the way you do it maybe I could figure out the url part later. So I put everythinging in one directory, named the code file test.php

Named the file I put the include command in test10.php

and then put a few files in the same directory named test.html etc.

But it won't pull up the files. Even thought it says "failed to open file
test.html."

I have good luck with inlcude commands so don't know what the problem is, here is how mine looks.

<?php
include 'test.php';
?>

I am looking at the code you gave above, is it missing any brackets anywhere? Does your include look different than mine? Otherwise it makes no sense why it works for you but not for me.

Thank you!

supermanjnk

11:53 am on Sep 27, 2006 (gmt 0)

10+ Year Member



If you are using test10.php you need to rename the htm's in the array to php...